Makefile for images. Cleanup.
This commit is contained in:
		
							parent
							
								
									1461c39400
								
							
						
					
					
						commit
						3cc530864b
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,3 +1,4 @@
 | 
			
		||||
build/
 | 
			
		||||
gallery/*.bmp
 | 
			
		||||
gallery/*.jpg
 | 
			
		||||
gallery/*.png
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								Makefile
									
									
									
									
									
								
							@ -1,11 +1,26 @@
 | 
			
		||||
.DEFAULT_GOAL := build
 | 
			
		||||
 | 
			
		||||
all: images download
 | 
			
		||||
SRC_IMAGES := $(wildcard gallery/*.jpg)
 | 
			
		||||
DST_IMAGES := $(sort $(addprefix build/,$(addsuffix .bmp,$(notdir $(basename $(SRC_IMAGES))))))
 | 
			
		||||
 | 
			
		||||
images:
 | 
			
		||||
	cd gallery && for F in *.jpg; do ./convert_image.sh $F $F.bmp
 | 
			
		||||
all: clean build
 | 
			
		||||
 | 
			
		||||
download: jokes.json
 | 
			
		||||
 | 
			
		||||
jokes.json:
 | 
			
		||||
	curl -o jokes.json https://github.com/wiz64/superfun/raw/main/database/ichd/jokes-file.json
 | 
			
		||||
jokes.json: build-dir
 | 
			
		||||
	curl -o build/jokes.json https://github.com/wiz64/superfun/raw/main/database/ichd/jokes-file.json
 | 
			
		||||
 | 
			
		||||
build: build-dir images download
 | 
			
		||||
 | 
			
		||||
build-dir:
 | 
			
		||||
	mkdir -p build
 | 
			
		||||
 | 
			
		||||
images: $(DST_IMAGES)
 | 
			
		||||
 | 
			
		||||
$(DST_IMAGES): build/%.bmp: gallery/%.jpg
 | 
			
		||||
	./convert_image.sh $< $@
 | 
			
		||||
 | 
			
		||||
.PHONY: clean
 | 
			
		||||
clean:
 | 
			
		||||
	rm -rf build/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.py
									
									
									
									
									
								
							@ -48,5 +48,5 @@ while True:
 | 
			
		||||
    
 | 
			
		||||
    print("")
 | 
			
		||||
    gc.collect()
 | 
			
		||||
    epd.delay_ms(10000 * 1)
 | 
			
		||||
    epd.delay_ms(60000 * 10)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								palette.bmp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								palette.bmp
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 194 B  | 
							
								
								
									
										38
									
								
								sdcard_test.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								sdcard_test.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,38 @@
 | 
			
		||||
import machine
 | 
			
		||||
import sdcard
 | 
			
		||||
import uos
 | 
			
		||||
 | 
			
		||||
# Assign chip select (CS) pin (and start it high)
 | 
			
		||||
cs = machine.Pin(17, machine.Pin.OUT)
 | 
			
		||||
 | 
			
		||||
# Intialize SPI peripheral (start with 1 MHz)
 | 
			
		||||
spi = machine.SPI(0,
 | 
			
		||||
                  baudrate=1000000,
 | 
			
		||||
                  polarity=0,
 | 
			
		||||
                  phase=0,
 | 
			
		||||
                  bits=8,
 | 
			
		||||
                  firstbit=machine.SPI.MSB,
 | 
			
		||||
                  sck=machine.Pin(18),
 | 
			
		||||
                  mosi=machine.Pin(19),
 | 
			
		||||
                  miso=machine.Pin(16))
 | 
			
		||||
 | 
			
		||||
# Initialize SD card
 | 
			
		||||
sd = sdcard.SDCard(spi, cs)
 | 
			
		||||
 | 
			
		||||
sd_path = "/sd"
 | 
			
		||||
 | 
			
		||||
# Mount filesystem
 | 
			
		||||
vfs = uos.VfsFat(sd)
 | 
			
		||||
uos.mount(vfs, sd_path)
 | 
			
		||||
 | 
			
		||||
# Create a file and write something to it
 | 
			
		||||
with open(sd_path + "/test01.txt", "w") as file:
 | 
			
		||||
    file.write("Hello, SD World!\r\n")
 | 
			
		||||
    file.write("This is a test\r\n")
 | 
			
		||||
 | 
			
		||||
# Open the file we just created and read from it
 | 
			
		||||
with open(sd_path + "/test01.txt", "r") as file:
 | 
			
		||||
    data = file.read()
 | 
			
		||||
    print(data)
 | 
			
		||||
 | 
			
		||||
uos.mount(sd_path)
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user