├── .gitignore ├── Examples ├── Inkplate10 │ ├── RTC.py │ ├── Sd_card_example_files │ │ ├── 1.bmp │ │ └── text.txt │ ├── basicBW.py │ ├── basicGrayscale.py │ ├── batteryAndTemperatureRead.py │ ├── drawGrayscaleImage.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ ├── gpio_expander.py │ └── touchpads.py ├── Inkplate2 │ ├── basicBWR.py │ ├── drawColorImage.py │ └── exampleNetwork.py ├── Inkplate4 │ ├── Sd_card_example_files │ │ ├── 1.bmp │ │ └── text.txt │ ├── basicBWR.py │ ├── batteryRead.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ └── gpio_expander.py ├── Inkplate5 │ ├── RTC.py │ ├── Sd_card_example_files │ │ ├── 1.bmp │ │ └── text.txt │ ├── basicBW.py │ ├── basicGrayscale.py │ ├── batteryAndTemperatureRead.py │ ├── drawGrayscaleImage.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ └── gpio_expander.py ├── Inkplate6 │ ├── RTC.py │ ├── Sd_card_example_files │ │ ├── 1.bmp │ │ └── text.txt │ ├── basicBW.py │ ├── basicGrayscale.py │ ├── batteryAndTemperatureRead.py │ ├── drawGrayscaleImage.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ ├── gpio_expander.py │ └── touchpads.py ├── Inkplate6COLOR │ ├── RTC.py │ ├── Sd_card_example_files │ │ ├── 1.bmp │ │ └── text.txt │ ├── basicCOLOR.py │ ├── batteryRead.py │ ├── drawColorImage.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ ├── gpio_expander.py │ └── touchpads.py ├── Inkplate6PLUS │ ├── RTC.py │ ├── basicBW.py │ ├── basicGrayscale.py │ ├── batteryAndTemperatureRead.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ ├── frontlight.py │ └── touchscreen.py ├── Inkplate7 │ ├── Sd_card_example_files │ │ ├── 1.bmp │ │ └── text.txt │ ├── basicBWR.py │ ├── batteryRead.py │ ├── drawColorImage.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ └── gpio_expander.py ├── Soldered_Inkplate10 │ ├── RTC.py │ ├── Sd_card_example_files │ │ ├── 1.bmp │ │ └── text.txt │ ├── basicBW.py │ ├── basicGrayscale.py │ ├── batteryAndTemperatureRead.py │ ├── drawGrayscaleImage.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ └── gpio_expander.py ├── Soldered_Inkplate6 │ ├── RTC.py │ ├── Sd_card_example_files │ │ ├── 1.bmp │ │ └── text.txt │ ├── basicBW.py │ ├── basicGrayscale.py │ ├── batteryAndTemperatureRead.py │ ├── drawGrayscaleImage.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ └── gpio_expander.py └── Soldered_Inkplate6PLUS │ ├── RTC.py │ ├── Sd_card_example_files │ ├── 1.bmp │ └── text.txt │ ├── basicBW.py │ ├── basicGrayscale.py │ ├── batteryAndTemperatureRead.py │ ├── drawGrayscaleImage.py │ ├── exampleNetwork.py │ ├── exampleSd.py │ ├── frontlight.py │ ├── gpio_expander.py │ └── touchscreen.py ├── LICENSE ├── PCAL6416A.py ├── README.md ├── color_image_inkplate2.py ├── color_image_inkplate6COLOR.py ├── color_image_inkplate7.py ├── esp32spiram-20220117-v1.18.bin ├── gfx.py ├── gfx_standard_font_01.py ├── i2c_scanner.py ├── image.py ├── inkplate10.py ├── inkplate2.py ├── inkplate4.py ├── inkplate5.py ├── inkplate6.py ├── inkplate6COLOR.py ├── inkplate6PLUS.py ├── inkplate7.py ├── mcp23017.py ├── pyboard.py ├── shapes.py ├── soldered_inkplate10.py ├── soldered_inkplate6.py ├── soldered_inkplate6PLUS.py └── soldered_logo.py /.gitignore: -------------------------------------------------------------------------------- 1 | board_config.py 2 | board_config_*.py 3 | init.mpf 4 | lib 5 | .vscode 6 | i2c_scanner.py 7 | -------------------------------------------------------------------------------- /Examples/Inkplate10/RTC.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to use the onboard RTC to preserve time across reboots 2 | 3 | # Include all the required libraries 4 | from inkplate10 import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # This is how to set the RTC's time 25 | # Arguments are hour, minute, seconds 26 | display.rtcSetTime(9,39,10) 27 | # And this is the date 28 | # Arguments are weekday, day in month, month and year 29 | display.rtcSetDate(5,9,2,2024) 30 | 31 | # Show the set time 32 | print(display.rtcGetData()) 33 | 34 | # Let's wait 10 seconds 35 | time.sleep(10) 36 | 37 | # Let's see if the time has updated 38 | print(display.rtcGetData()) -------------------------------------------------------------------------------- /Examples/Inkplate10/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Inkplate10/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Inkplate10/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Inkplate10/basicBW.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw basic black and white shapes 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include all the required libraries 5 | from inkplate10 import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object in 1-bit mode, black and white colors only 10 | # For 2-bit grayscale, see basicGrayscale.py 11 | display = Inkplate(Inkplate.INKPLATE_1BIT) 12 | 13 | # Main function 14 | if __name__ == "__main__": 15 | 16 | # Initialize the display, needs to be called only once 17 | display.begin() 18 | 19 | # Clear the frame buffer 20 | display.clearDisplay() 21 | 22 | # This has to be called every time you want to update the screen 23 | # Drawing or printing text will have no effect on the display itself before you call this function 24 | display.display() 25 | 26 | # Let's draw some shapes! 27 | # This example will draw shapes around the upper left corner, and then rotate the screen 28 | # This creates a symmetrical-looking pattern of various shapes 29 | for r in range(4): 30 | 31 | # Sets the screen rotation 32 | display.setRotation(r) 33 | 34 | # All drawing functions 35 | display.drawPixel(100, 100, display.BLACK) 36 | display.drawRect(50, 50, 75, 75, display.BLACK) 37 | display.drawCircle(200, 200, 30, display.BLACK) 38 | display.fillCircle(300, 300, 30, display.BLACK) 39 | display.drawFastHLine(20, 100, 50, display.BLACK) 40 | display.drawFastVLine(100, 20, 50, display.BLACK) 41 | display.drawLine(100, 100, 400, 400, display.BLACK) 42 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 43 | display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK) 44 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 45 | 46 | # If it's rotation 0 or 2, also add this filled triangle 47 | if display.rotation % 2 == 0: 48 | display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK) 49 | 50 | # Show on the display! 51 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 52 | # This makes for a faster update 53 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 54 | # This ensures the image retains it's quality 55 | display.partialUpdate() 56 | 57 | # Wait 5 seconds 58 | time.sleep(5) 59 | 60 | # Reset the rotation 61 | display.setRotation(0) 62 | 63 | # We've drawn the pattern, now let's draw the Soldered logo right in the middle 64 | display.drawBitmap(494, 391, soldered_logo, 211, 44) 65 | 66 | # Show on the display 67 | display.display() 68 | -------------------------------------------------------------------------------- /Examples/Inkplate10/basicGrayscale.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw different shades of gray using grayscale mode 2 | 3 | # Include needed libraries 4 | from inkplate10 import Inkplate 5 | from soldered_logo import * 6 | import time 7 | 8 | # Create Inkplate object in 2-bit grayscale mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Draw pallet of posible shades 25 | # 0 being the lightest (white), 3 being the darkest 26 | display.writeFillRect(0, 0, 25, 825, 3) 27 | display.writeFillRect(25, 0, 25, 825, 2) 28 | display.writeFillRect(50, 0, 25, 825, 1) 29 | display.writeFillRect(75, 0, 25, 825, 0) 30 | 31 | # Show on the display 32 | display.display() 33 | 34 | # Wait 3 seconds 35 | time.sleep(3) 36 | 37 | # Let's draw the Soldered logo and show it on the display 38 | display.drawBitmap(248, 391, soldered_logo, 211, 44) 39 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate10/batteryAndTemperatureRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also the temperature from the TPS and print it on the screen 3 | 4 | # Include needed libraries 5 | from inkplate10 import Inkplate 6 | import time 7 | 8 | # Create Inkplate object in 1-bit mode, black and white colors only 9 | # For 2-bit grayscale, see basicGrayscale.py 10 | display = Inkplate(Inkplate.INKPLATE_1BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # Get the battery reading as a string 26 | battery = str(display.readBattery()) 27 | 28 | # Set text size to double from the original size, so we can see the text better 29 | display.setTextSize(2) 30 | 31 | # Print the text at coordinates 100,100 (from the upper left corner) 32 | display.printText(100, 100, "Battery voltage: " + battery + "V") 33 | 34 | # Show it on the display 35 | display.display() 36 | 37 | # Wait 5 seconds 38 | time.sleep(5) 39 | 40 | # Get the temperature reading, also as a string 41 | temperature = str(display.readTemperature()) 42 | 43 | # Print the text at coordinates 100, 150, and also add the measurement unit 44 | display.printText(100, 150, "Temperature: " + temperature + "C") 45 | 46 | # Show it on the display 47 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate10/drawGrayscaleImage.py: -------------------------------------------------------------------------------- 1 | # This example shows how to draw a grayscale image from the SD card 2 | # Copy the image from Sd_card_example_files and place it on the microSD card 3 | # NOTE: This takes quite a while as MicroPython can be a bit slow 4 | 5 | # Include needed libraries 6 | from inkplate10 import Inkplate 7 | import os, time 8 | 9 | # Init display in 2bit mode, important 10 | display = Inkplate(Inkplate.INKPLATE_2BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # SD Card must be initialised with this function 26 | display.initSDCard() 27 | 28 | # Wait one second so we're totally sure it's initialized 29 | time.sleep(1) 30 | 31 | # Wake the SD (power ON) 32 | display.SDCardWake() 33 | 34 | # Draw image in grayscale and display it 35 | # Also print a message before and after 36 | print("Starting to draw image from file!") 37 | display.drawImageFile(0, 0, "sd/1.bmp", False) 38 | display.display() 39 | print("Finished drawing image from file!") 40 | 41 | # Put the SD card back to sleep to save power 42 | display.SDCardSleep() 43 | # To turn it back on, use: 44 | # display.SDCardWake() 45 | -------------------------------------------------------------------------------- /Examples/Inkplate10/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from inkplate10 import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object in 1-bit mode 56 | display = Inkplate(Inkplate.INKPLATE_1BIT) 57 | display.begin() 58 | 59 | # Set text size to double from the original size, so we can see the text better 60 | display.setTextSize(2) 61 | 62 | # Print response line by line 63 | cnt = 0 64 | for x in response.split("\n"): 65 | display.printText( 66 | 10, 20 + cnt, x.upper() 67 | ) # Default font has only upper case letters 68 | cnt += 20 69 | 70 | # Display image from buffer in full refresh 71 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate10/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from inkplate10 import Inkplate 7 | 8 | # Create Inkplate object in 2-bit (grayscale) mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images or in 1-bit mode 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate10/gpio_expander.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the GPIO expander's pins 2 | # Soldered Inkplate10 has an internal and external GPIO expander 3 | # See below which pins are available 4 | 5 | # Include needed libraries 6 | import time 7 | from mcp23017 import * 8 | from inkplate10 import Inkplate 9 | 10 | # Create Inkplate object in 1-bit mode, black and white colors only 11 | # For 2-bit grayscale, see basicGrayscale.py 12 | display = Inkplate(Inkplate.INKPLATE_1BIT) 13 | 14 | # Main function 15 | if __name__ == "__main__": 16 | 17 | # Initialize the display, needs to be called only once 18 | display.begin() 19 | 20 | # pin = display.gpioExpanderPin(gpioExpander,pin,mode) 21 | # Supported gpio expanders on Soldered Inkplate 10: 1, 2 (internal, external) 22 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 23 | # The pins are listed below 24 | 25 | # Declare all the available pins as output: 26 | 27 | expander1_P1_1 = display.gpioExpanderPin(1, 9, modeOUTPUT) 28 | expander1_P1_2 = display.gpioExpanderPin(1, 10, modeOUTPUT) 29 | expander1_P1_3 = display.gpioExpanderPin(1, 11, modeOUTPUT) 30 | expander1_P1_4 = display.gpioExpanderPin(1, 12, modeOUTPUT) 31 | expander1_P1_5 = display.gpioExpanderPin(1, 13, modeOUTPUT) 32 | expander1_P1_6 = display.gpioExpanderPin(1, 14, modeOUTPUT) 33 | expander1_P1_7 = display.gpioExpanderPin(1, 15, modeOUTPUT) 34 | 35 | expander2_P0_0 = display.gpioExpanderPin(2, 0, modeOUTPUT) 36 | expander2_P0_1 = display.gpioExpanderPin(2, 1, modeOUTPUT) 37 | expander2_P0_2 = display.gpioExpanderPin(2, 2, modeOUTPUT) 38 | expander2_P0_3 = display.gpioExpanderPin(2, 3, modeOUTPUT) 39 | expander2_P0_4 = display.gpioExpanderPin(2, 4, modeOUTPUT) 40 | expander2_P0_5 = display.gpioExpanderPin(2, 5, modeOUTPUT) 41 | expander2_P0_6 = display.gpioExpanderPin(2, 6, modeOUTPUT) 42 | expander2_P0_7 = display.gpioExpanderPin(2, 7, modeOUTPUT) 43 | 44 | expander2_P1_0 = display.gpioExpanderPin(2, 8, modeOUTPUT) 45 | expander2_P1_1 = display.gpioExpanderPin(2, 9, modeOUTPUT) 46 | expander2_P1_2 = display.gpioExpanderPin(2, 10, modeOUTPUT) 47 | expander2_P1_3 = display.gpioExpanderPin(2, 11, modeOUTPUT) 48 | expander2_P1_4 = display.gpioExpanderPin(2, 12, modeOUTPUT) 49 | expander2_P1_5 = display.gpioExpanderPin(2, 13, modeOUTPUT) 50 | expander2_P1_6 = display.gpioExpanderPin(2, 14, modeOUTPUT) 51 | expander2_P1_7 = display.gpioExpanderPin(2, 15, modeOUTPUT) 52 | 53 | # Take the previously declared pin 1_5 on expander 2 and blink it 54 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 55 | while (1): 56 | expander2_P1_5.digitalWrite(1) 57 | time.sleep(0.5) 58 | expander2_P1_5.digitalWrite(0) 59 | time.sleep(0.5) 60 | # Infinite loop, this goes on forever -------------------------------------------------------------------------------- /Examples/Inkplate10/touchpads.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the touchpads 2 | # Only older models of Inkplate10 (e-Radionica Inkplate 10) have them 3 | 4 | # Include required libraries 5 | from inkplate10 import Inkplate 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Create some coordinates and a radius for drawing a circle 12 | circle_x = 400 13 | circle_y = 300 14 | circle_r = 40 15 | 16 | # Main function 17 | if __name__ == "__main__": 18 | 19 | # Initialize the display, needs to be called only once 20 | display.begin() 21 | 22 | # Clear the frame buffer 23 | display.clearDisplay() 24 | 25 | # This has to be called every time you want to update the screen 26 | # Drawing or printing text will have no effect on the display itself before you call this function 27 | display.display() 28 | 29 | # Function to show text at the top of the screen 30 | # Needs to be called every time we clear the display to re-draw the text 31 | def draw_top_text(): 32 | display.setTextSize(2) 33 | display.printText(100, 10, "TOUCHPADS EXAMPLE! 1, 3 TO MOVE CIRCLE, 2 TO RESET") 34 | 35 | # Call it 36 | draw_top_text() 37 | 38 | # Touchpads definitions 39 | touch1, touch2, touch3 = display.TOUCH1, display.TOUCH2, display.TOUCH3 40 | 41 | # Draw the initial circle for touchpad demonstration 42 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 43 | 44 | # Show everything on the display 45 | display.display() 46 | 47 | # Start infinite loop 48 | while True: 49 | # If a touchpad is pressed, move the circle and redraw everything 50 | # Touch 1 moves the circle to the left 51 | if touch1(): 52 | circle_x -= 40 53 | display.clearDisplay() 54 | draw_top_text() 55 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 56 | # Show on the display! 57 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 58 | # This makes for a faster update 59 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 60 | # This ensures the image retains it's quality 61 | display.partialUpdate() 62 | 63 | # Touch 2 will reset the position of the circle 64 | if touch2(): 65 | circle_x = 400 66 | circle_y = 300 67 | circle_r = 40 68 | display.clearDisplay() 69 | draw_top_text() 70 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 71 | display.display() # Do a full refresh also 72 | 73 | # Touch 3 will move the circle to the right 74 | if touch3(): 75 | circle_x += 40 76 | display.clearDisplay() 77 | draw_top_text() 78 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 79 | display.partialUpdate() -------------------------------------------------------------------------------- /Examples/Inkplate2/basicBWR.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw shapes and text in black, white and red 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include needed libraries 5 | from inkplate2 import Inkplate 6 | from soldered_logo import * 7 | 8 | # Create Inkplate object 9 | display = Inkplate() 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Print some text at location x = 5 px, y = 8 px 18 | # So, close to the upper left corner 19 | display.printText(5, 8, "Welcome to Inkplate 2") 20 | 21 | # Print some larger text in red 22 | display.setTextSize(2) 23 | display.printText(5, 20, "MicroPython!", display.RED) 24 | 25 | # Fill a black circle and draw some white and red circles inside it 26 | display.fillCircle(178, 16, 15, display.BLACK) 27 | display.drawCircle(178, 16, 13, display.RED) 28 | display.drawCircle(178, 16, 9, display.WHITE) 29 | display.drawCircle(178, 16, 4, display.RED) 30 | 31 | # Draw a red checkerboard pattern with a loop 32 | for x in range(30): 33 | display.fillRect(0 + (5*x*2), 38, 5, 5, display.RED) 34 | 35 | for x in range(30): 36 | display.fillRect(5 + (5*x*2), 42, 5, 5, display.RED) 37 | 38 | # Draw some horizontal lines 39 | display.drawLine(0, 49, 214, 49, display.BLACK) 40 | display.drawLine(0, 51, 214, 51, display.RED) 41 | display.drawLine(0, 53, 214, 53, display.BLACK) 42 | display.drawLine(0, 55, 214, 55, display.RED) 43 | 44 | # Draw the soldered logo as a bitmap image in red 45 | display.drawBitmap(0, 58, soldered_logo, 211, 44, display.RED) 46 | 47 | # Display everything on Inkplate's display 48 | # This function must be called after drawing, or else the display won't update 49 | # The display flickers when it updates and it takes a while, this is normal 50 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate2/drawColorImage.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw a color image (black, white, red) 2 | # The pixel format is four pixels per byte, each pixel two bits 3 | # 00 is Black 4 | # 01 is White 5 | # 10 is Red 6 | 7 | # Include needed libraries 8 | from inkplate2 import Inkplate 9 | 10 | # Import the image 11 | # It should also be copied to Inkplate when copying other libraries 12 | # Check the README for more info 13 | from color_image_inkplate2 import color_image_inkplate2 14 | 15 | # Create Inkplate object 16 | display = Inkplate() 17 | 18 | # Main function 19 | if __name__ == "__main__": 20 | 21 | # Initialize the display, needs to be called only once 22 | display.begin() 23 | 24 | # color_image_inkplate2 is 212x104px, draw it over the whole screen 25 | # Arguments are: x start, y start, width, height, and then the image buffer 26 | display.drawColorImage(0, 0, 212, 104, color_image_inkplate2) 27 | 28 | # Show it on the display 29 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate2/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from inkplate2 import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "Soldered" 11 | password = "dasduino" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object 56 | display = Inkplate() 57 | display.begin() 58 | 59 | # Print response line by line 60 | cnt = 0 61 | for x in response.split("\n"): 62 | display.printText( 63 | 2, 2 + cnt, x.upper() 64 | ) # Default font has only upper case letters 65 | cnt += 10 66 | 67 | # Also print to terminal because the screen is small 68 | print(x) 69 | 70 | # Display image from buffer 71 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate4/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Inkplate4/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Inkplate4/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Inkplate4/basicBWR.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw shapes and text in black, white and red 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include needed libraries 5 | from inkplate4 import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object 10 | display = Inkplate() 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # Let's draw some shapes! 26 | # This example will draw shapes around the upper left corner, and then rotate the screen 27 | # This creates a symmetrical-looking pattern of various shapes 28 | for r in range(4): 29 | 30 | # Sets the screen rotation 31 | display.setRotation(r) 32 | 33 | # All drawing functions 34 | # Draw some of the elements in red so we can see the color 35 | display.drawPixel(20, 5, display.BLACK) 36 | display.drawRect(10, 40, 20, 60, display.RED) 37 | display.drawCircle(30, 60, 15, display.RED) 38 | display.fillCircle(70, 30, 15, display.BLACK) 39 | display.drawFastHLine(30, 75, 100, display.BLACK) 40 | display.drawFastVLine(100, 10, 40, display.BLACK) 41 | display.drawLine(5, 5, 150, 150, display.BLACK) 42 | display.drawRoundRect(160, 5, 20, 60, 10, display.BLACK) 43 | display.fillRoundRect(150, 70, 60, 15, 10, display.RED) 44 | display.drawTriangle(5, 196, 60, 196, 33, 149, display.RED) 45 | 46 | # Show on the display! 47 | # This function must be called in order for the display to update 48 | display.display() 49 | 50 | # Wait 5 seconds 51 | time.sleep(5) 52 | 53 | # Reset the rotation 54 | display.setRotation(0) 55 | 56 | # Let's draw the Soldered logo right in the middle 57 | # First, fill the background of the image white 58 | display.fillRect(94, 128, 211, 44, display.WHITE) # Draw white background 59 | # Now, draw the logo 60 | display.drawBitmap(94, 128, soldered_logo, 211, 44, display.RED) 61 | 62 | # Show on the display 63 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate4/batteryRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also print it on the screen 3 | 4 | # Include needed libraries 5 | from inkplate4 import Inkplate 6 | import time 7 | 8 | # Create Inkplate object 9 | display = Inkplate() 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Get the battery reading as a string 25 | battery = str(display.readBattery()) 26 | 27 | # Set text size to double from the original size, so we can see the text better 28 | display.setTextSize(2) 29 | 30 | # Print the text at coordinates 50, 50 (from the upper left corner) 31 | display.printText(50, 50, "Battery voltage: " + battery + "V") 32 | 33 | # Show it on the display 34 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate4/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from inkplate4 import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object 56 | display = Inkplate() 57 | display.begin() 58 | 59 | # Set text size to double from the original size, so we can see the text better 60 | display.setTextSize(2) 61 | 62 | # Print response line by line 63 | cnt = 0 64 | for x in response.split("\n"): 65 | display.printText( 66 | 10, 20 + cnt, x.upper() 67 | ) # Default font has only upper case letters 68 | cnt += 20 69 | 70 | # Display image from buffer 71 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate4/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from inkplate4 import Inkplate 7 | 8 | # Create Inkplate object 9 | display = Inkplate() 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate4/gpio_expander.py: -------------------------------------------------------------------------------- 1 | import time 2 | from PCAL6416A import * 3 | from inkplate4 import Inkplate 4 | 5 | display = Inkplate() 6 | 7 | # This script demonstrates using all the available GPIO expander pins as output 8 | 9 | if __name__ == "__main__": 10 | # Must be called before using, line in Arduino 11 | display.begin() 12 | 13 | # pin = display.gpioExpanderPin(gpioExpander,pin,mode) 14 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 15 | # Supported pins on Soldered Inkplate 4 are listed below 16 | 17 | expander_P0_0 = display.gpioExpanderPin(0, modeOUTPUT) 18 | expander_P0_1 = display.gpioExpanderPin(1, modeOUTPUT) 19 | expander_P0_2 = display.gpioExpanderPin(2, modeOUTPUT) 20 | expander_P0_3 = display.gpioExpanderPin(3, modeOUTPUT) 21 | expander_P0_4 = display.gpioExpanderPin(4, modeOUTPUT) 22 | expander_P0_5 = display.gpioExpanderPin(5, modeOUTPUT) 23 | expander_P0_6 = display.gpioExpanderPin(6, modeOUTPUT) 24 | expander_P0_7 = display.gpioExpanderPin(7, modeOUTPUT) 25 | 26 | expander_P1_0 = display.gpioExpanderPin(8, modeOUTPUT) 27 | expander_P1_1 = display.gpioExpanderPin(9, modeOUTPUT) 28 | expander_P1_2 = display.gpioExpanderPin(10, modeOUTPUT) 29 | expander_P1_3 = display.gpioExpanderPin(11, modeOUTPUT) 30 | expander_P1_4 = display.gpioExpanderPin(12, modeOUTPUT) 31 | expander_P1_5 = display.gpioExpanderPin(13, modeOUTPUT) 32 | expander_P1_6 = display.gpioExpanderPin(14, modeOUTPUT) 33 | expander_P1_7 = display.gpioExpanderPin(15, modeOUTPUT) 34 | 35 | # Take the previously declared pin 1_5 and blink it 36 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 37 | while (1): 38 | expander_P1_5.digitalWrite(1) 39 | time.sleep(0.5) 40 | expander_P1_5.digitalWrite(0) 41 | time.sleep(0.5) 42 | # Infinite loop, this goes on forever 43 | -------------------------------------------------------------------------------- /Examples/Inkplate5/RTC.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to use the onboard RTC to preserve time across reboots 2 | 3 | # Include all the required libraries 4 | from inkplate5 import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # This is how to set the RTC's time 25 | # Arguments are hour, minute, seconds 26 | display.rtcSetTime(9,39,10) 27 | # And this is the date 28 | # Arguments are weekday, day in month, month and year 29 | display.rtcSetDate(5,9,2,2024) 30 | 31 | # Show the set time 32 | print(display.rtcGetData()) 33 | 34 | # Let's wait 10 seconds 35 | time.sleep(10) 36 | 37 | # Let's see if the time has updated 38 | print(display.rtcGetData()) -------------------------------------------------------------------------------- /Examples/Inkplate5/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Inkplate5/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Inkplate5/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Inkplate5/basicBW.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw basic black and white shapes 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include all the required libraries 5 | from inkplate5 import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object in 1-bit mode, black and white colors only 10 | # For 2-bit grayscale, see basicGrayscale.py 11 | display = Inkplate(Inkplate.INKPLATE_1BIT) 12 | 13 | # Main function 14 | if __name__ == "__main__": 15 | 16 | # Initialize the display, needs to be called only once 17 | display.begin() 18 | 19 | # Clear the frame buffer 20 | display.clearDisplay() 21 | 22 | # This has to be called every time you want to update the screen 23 | # Drawing or printing text will have no effect on the display itself before you call this function 24 | display.display() 25 | 26 | # Let's draw some shapes! 27 | # This example will draw shapes around the upper left corner, and then rotate the screen 28 | # This creates a symmetrical-looking pattern of various shapes 29 | for r in range(4): 30 | 31 | # Sets the screen rotation 32 | display.setRotation(r) 33 | 34 | # All drawing functions 35 | display.drawPixel(100, 100, display.BLACK) 36 | display.drawRect(50, 50, 75, 75, display.BLACK) 37 | display.drawCircle(200, 200, 30, display.BLACK) 38 | display.fillCircle(300, 300, 30, display.BLACK) 39 | display.drawFastHLine(20, 100, 50, display.BLACK) 40 | display.drawFastVLine(100, 20, 50, display.BLACK) 41 | display.drawLine(100, 100, 400, 400, display.BLACK) 42 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 43 | display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK) 44 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 45 | 46 | # If it's rotation 0 or 2, also add this filled triangle 47 | if display.rotation % 2 == 0: 48 | display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK) 49 | 50 | # Show on the display! 51 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 52 | # This makes for a faster update 53 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 54 | # This ensures the image retains it's quality 55 | display.partialUpdate() 56 | 57 | # Wait 5 seconds 58 | time.sleep(5) 59 | 60 | # Reset the rotation 61 | display.setRotation(0) 62 | 63 | # We've drawn the pattern, now let's draw the Soldered logo right in the middle 64 | display.drawBitmap(374, 248, soldered_logo, 211, 44) 65 | 66 | # Show on the display 67 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate5/basicGrayscale.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw different shades of gray using grayscale mode 2 | 3 | # Include needed libraries 4 | from inkplate5 import Inkplate 5 | from soldered_logo import * 6 | import time 7 | 8 | # Create Inkplate object in 2-bit grayscale mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Draw pallet of posible shades 25 | # 0 being the lightest (white), 3 being the darkest 26 | display.writeFillRect(0, 0, 25, 600, 3) 27 | display.writeFillRect(25, 0, 25, 600, 2) 28 | display.writeFillRect(50, 0, 25, 600, 1) 29 | display.writeFillRect(75, 0, 25, 600, 0) 30 | 31 | # Show on the display 32 | display.display() 33 | 34 | # Wait 3 seconds 35 | time.sleep(3) 36 | 37 | # Let's draw the Soldered logo and show it on the display 38 | display.drawBitmap(374, 248, soldered_logo, 211, 44) 39 | 40 | display.display() 41 | -------------------------------------------------------------------------------- /Examples/Inkplate5/batteryAndTemperatureRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also the temperature from the TPS and print it on the screen 3 | 4 | # Include needed libraries 5 | from inkplate5 import Inkplate 6 | import time 7 | 8 | # Create Inkplate object in 1-bit mode, black and white colors only 9 | # For 2-bit grayscale, see basicGrayscale.py 10 | display = Inkplate(Inkplate.INKPLATE_1BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # Get the battery reading as a string 26 | battery = str(display.readBattery()) 27 | 28 | # Set text size to double from the original size, so we can see the text better 29 | display.setTextSize(2) 30 | 31 | # Print the text at coordinates 100,100 (from the upper left corner) 32 | display.printText(100, 100, "Battery voltage: " + battery + "V") 33 | 34 | # Show it on the display 35 | display.display() 36 | 37 | # Wait 5 seconds 38 | time.sleep(5) 39 | 40 | # Get the temperature reading, also as a string 41 | temperature = str(display.readTemperature()) 42 | 43 | # Print the text at coordinates 100, 150, and also add the measurement unit 44 | display.printText(100, 150, "Temperature: " + temperature + "C") 45 | 46 | # Show it on the display 47 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate5/drawGrayscaleImage.py: -------------------------------------------------------------------------------- 1 | # This example shows how to draw a grayscale image from the SD card 2 | # Copy the image from Sd_card_example_files and place it on the microSD card 3 | # NOTE: This takes quite a while as MicroPython can be a bit slow 4 | 5 | # Include needed libraries 6 | from inkplate5 import Inkplate 7 | import os, time 8 | 9 | # Init display in 2bit mode, important 10 | display = Inkplate(Inkplate.INKPLATE_2BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # SD Card must be initialised with this function 26 | display.initSDCard() 27 | 28 | # Wait one second so we're totally sure it's initialized 29 | time.sleep(1) 30 | 31 | # Wake the SD (power ON) 32 | display.SDCardWake() 33 | 34 | # Draw image in grayscale and display it 35 | # Also print a message before and after 36 | print("Starting to draw image from file!") 37 | display.drawImageFile(0, 0, "sd/1.bmp", False) 38 | display.display() 39 | print("Finished drawing image from file!") 40 | 41 | # Put the SD card back to sleep to save power 42 | display.SDCardSleep() 43 | # To turn it back on, use: 44 | # display.SDCardWake() 45 | -------------------------------------------------------------------------------- /Examples/Inkplate5/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | import network 2 | import time 3 | from inkplate5 import Inkplate 4 | 5 | ssid = "" 6 | password = "" 7 | 8 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 9 | def do_connect(): 10 | import network 11 | 12 | sta_if = network.WLAN(network.STA_IF) 13 | if not sta_if.isconnected(): 14 | print("connecting to network...") 15 | sta_if.active(True) 16 | sta_if.connect(ssid, password) 17 | while not sta_if.isconnected(): 18 | pass 19 | print("network config:", sta_if.ifconfig()) 20 | 21 | 22 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 23 | def http_get(url): 24 | import socket 25 | 26 | res = "" 27 | _, _, host, path = url.split("/", 3) 28 | addr = socket.getaddrinfo(host, 80)[0][-1] 29 | s = socket.socket() 30 | s.connect(addr) 31 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 32 | while True: 33 | data = s.recv(100) 34 | if data: 35 | res += str(data, "utf8") 36 | else: 37 | break 38 | s.close() 39 | 40 | return res 41 | 42 | 43 | # Calling functions defined above 44 | do_connect() 45 | response = http_get("http://micropython.org/ks/test.html") 46 | 47 | # Initialise our Inkplate object 48 | display = Inkplate(Inkplate.INKPLATE_1BIT) 49 | display.begin() 50 | display.setTextSize(2) 51 | # Print response in lines 52 | cnt = 0 53 | for x in response.split("\n"): 54 | display.printText( 55 | 20, 20 + cnt, x.upper() 56 | ) # Default font has only upper case letters 57 | cnt += 20 58 | 59 | # Display image from buffer 60 | display.display() 61 | -------------------------------------------------------------------------------- /Examples/Inkplate5/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from inkplate5 import Inkplate 7 | 8 | # Create Inkplate object in 2-bit (grayscale) mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images or in 1-bit mode 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate5/gpio_expander.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the GPIO expander's pins 2 | # See below which pins are available 3 | 4 | # Include needed libraries 5 | import time 6 | from PCAL6416A import * 7 | from inkplate5 import Inkplate 8 | 9 | # Create Inkplate object 10 | display = Inkplate() 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # pin = display.gpioExpanderPin(gpioExpander,pin,mode) 19 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 20 | # Supported pins on Soldered Inkplate 5 are listed below 21 | 22 | # Declare all the available pins as output: 23 | 24 | expander_P1_1 = display.gpioExpanderPin(9, modeOUTPUT) 25 | expander_P1_2 = display.gpioExpanderPin(10, modeOUTPUT) 26 | expander_P1_3 = display.gpioExpanderPin(11, modeOUTPUT) 27 | expander_P1_4 = display.gpioExpanderPin(12, modeOUTPUT) 28 | expander_P1_5 = display.gpioExpanderPin(13, modeOUTPUT) 29 | expander_P1_6 = display.gpioExpanderPin(14, modeOUTPUT) 30 | expander_P1_7 = display.gpioExpanderPin(15, modeOUTPUT) 31 | 32 | # Take the previously declared pin 1_5 and blink it 33 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 34 | while (1): 35 | expander_P1_5.digitalWrite(1) 36 | time.sleep(0.5) 37 | expander_P1_5.digitalWrite(0) 38 | time.sleep(0.5) 39 | # Infinite loop, this goes on forever -------------------------------------------------------------------------------- /Examples/Inkplate6/RTC.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to use the onboard RTC to preserve time across reboots 2 | 3 | # Include all the required libraries 4 | from inkplate6 import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # This is how to set the RTC's time 25 | # Arguments are hour, minute, seconds 26 | display.rtcSetTime(9,39,10) 27 | # And this is the date 28 | # Arguments are weekday, day in month, month and year 29 | display.rtcSetDate(5,9,2,2024) 30 | 31 | # Show the set time 32 | print(display.rtcGetData()) 33 | 34 | # Let's wait 10 seconds 35 | time.sleep(10) 36 | 37 | # Let's see if the time has updated 38 | print(display.rtcGetData()) -------------------------------------------------------------------------------- /Examples/Inkplate6/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Inkplate6/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Inkplate6/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Inkplate6/basicBW.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw basic black and white shapes 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include all the required libraries 5 | from inkplate6 import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object in 1-bit mode, black and white colors only 10 | # For 2-bit grayscale, see basicGrayscale.py 11 | display = Inkplate(Inkplate.INKPLATE_1BIT) 12 | 13 | # Main function 14 | if __name__ == "__main__": 15 | 16 | # Initialize the display, needs to be called only once 17 | display.begin() 18 | 19 | # Clear the frame buffer 20 | display.clearDisplay() 21 | 22 | # This has to be called every time you want to update the screen 23 | # Drawing or printing text will have no effect on the display itself before you call this function 24 | display.display() 25 | 26 | # Let's draw some shapes! 27 | # This example will draw shapes around the upper left corner, and then rotate the screen 28 | # This creates a symmetrical-looking pattern of various shapes 29 | for r in range(4): 30 | 31 | # Sets the screen rotation 32 | display.setRotation(r) 33 | 34 | # All the drawing functions 35 | display.drawPixel(100, 100, display.BLACK) 36 | display.drawRect(50, 50, 75, 75, display.BLACK) 37 | display.drawCircle(200, 200, 30, display.BLACK) 38 | display.fillCircle(300, 300, 30, display.BLACK) 39 | display.drawFastHLine(20, 100, 50, display.BLACK) 40 | display.drawFastVLine(100, 20, 50, display.BLACK) 41 | display.drawLine(100, 100, 400, 400, display.BLACK) 42 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 43 | display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK) 44 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 45 | 46 | # If it's rotation 0 or 2, also add this filled triangle 47 | if display.rotation % 2 == 0: 48 | display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK) 49 | 50 | # Show on the display! 51 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 52 | # This makes for a faster update 53 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 54 | # This ensures the image retains it's quality 55 | display.partialUpdate() 56 | 57 | # Wait 5 seconds 58 | time.sleep(5) 59 | 60 | # Reset the rotation 61 | display.setRotation(0) 62 | 63 | # We've drawn the pattern, now let's draw the Soldered logo right in the middle 64 | display.drawBitmap(294, 20, soldered_logo, 211, 44) 65 | 66 | # Show on the display 67 | display.display() 68 | -------------------------------------------------------------------------------- /Examples/Inkplate6/basicGrayscale.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw different shades of gray using grayscale mode 2 | 3 | # Include needed libraries 4 | from inkplate6 import Inkplate 5 | from soldered_logo import * 6 | import time 7 | 8 | # Create Inkplate object in 2-bit grayscale mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Draw pallet of posible shades 25 | # 0 being the lightest (white), 3 being the darkest 26 | display.writeFillRect(0, 0, 25, 600, 3) 27 | display.writeFillRect(25, 0, 25, 600, 2) 28 | display.writeFillRect(50, 0, 25, 600, 1) 29 | display.writeFillRect(75, 0, 25, 600, 0) 30 | 31 | # Show on the display 32 | display.display() 33 | 34 | # Wait 3 seconds 35 | time.sleep(3) 36 | 37 | # Let's draw the Soldered logo and show it on the display 38 | display.drawBitmap(294, 278, soldered_logo, 211, 44) 39 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6/batteryAndTemperatureRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also the temperature from the TPS and print it on the screen 3 | 4 | # Include needed libraries 5 | from inkplate6 import Inkplate 6 | import time 7 | 8 | # Create Inkplate object in 1-bit mode, black and white colors only 9 | # For 2-bit grayscale, see basicGrayscale.py 10 | display = Inkplate(Inkplate.INKPLATE_1BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # Get the battery reading as a string 26 | battery = str(display.readBattery()) 27 | 28 | # Set text size to double from the original size, so we can see the text better 29 | display.setTextSize(2) 30 | 31 | # Print the text at coordinates 100,100 (from the upper left corner) 32 | display.printText(100, 100, "Battery voltage: " + battery + "V") 33 | 34 | # Show it on the display 35 | display.display() 36 | 37 | # Wait 5 seconds 38 | time.sleep(5) 39 | 40 | # Get the temperature reading, also as a string 41 | temperature = str(display.readTemperature()) 42 | 43 | # Print the text at coordinates 100, 150, and also add the measurement unit 44 | display.printText(100, 150, "Temperature: " + temperature + "C") 45 | 46 | # Show it on the display 47 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6/drawGrayscaleImage.py: -------------------------------------------------------------------------------- 1 | # This example shows how to draw a grayscale image from the SD card 2 | # Copy the image from Sd_card_example_files and place it on the microSD card 3 | # NOTE: This takes quite a while as MicroPython can be a bit slow 4 | 5 | # Include needed libraries 6 | from inkplate6 import Inkplate 7 | import os, time 8 | 9 | # Init display in 2bit mode, important 10 | display = Inkplate(Inkplate.INKPLATE_2BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # SD Card must be initialised with this function 26 | display.initSDCard() 27 | 28 | # Wait one second so we're totally sure it's initialized 29 | time.sleep(1) 30 | 31 | # Wake the SD (power ON) 32 | display.SDCardWake() 33 | 34 | # Draw image in grayscale and display it 35 | # Also print a message before and after 36 | print("Starting to draw image from file!") 37 | display.drawImageFile(0, 0, "sd/1.bmp", False) 38 | display.display() 39 | print("Finished drawing image from file!") 40 | 41 | # Put the SD card back to sleep to save power 42 | display.SDCardSleep() 43 | # To turn it back on, use: 44 | # display.SDCardWake() 45 | -------------------------------------------------------------------------------- /Examples/Inkplate6/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from soldered_inkplate6 import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object in 1-bit mode 56 | display = Inkplate(Inkplate.INKPLATE_1BIT) 57 | display.begin() 58 | 59 | # Set text size to double from the original size, so we can see the text better 60 | display.setTextSize(2) 61 | 62 | # Print response line by line 63 | cnt = 0 64 | for x in response.split("\n"): 65 | display.printText( 66 | 10, 20 + cnt, x.upper() 67 | ) # Default font has only upper case letters 68 | cnt += 20 69 | 70 | # Display image from buffer in full refresh 71 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from inkplate6 import Inkplate 7 | 8 | # Create Inkplate object in 2-bit (grayscale) mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images or in 1-bit mode 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6/gpio_expander.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the GPIO expander's pins 2 | # Soldered Inkplate6 has an internal and external GPIO expander 3 | # See below which pins are available 4 | 5 | # Include needed libraries 6 | import time 7 | from PCAL6416A import * 8 | from soldered_inkplate6 import Inkplate 9 | 10 | # Create Inkplate object in 1-bit mode, black and white colors only 11 | # For 2-bit grayscale, see basicGrayscale.py 12 | display = Inkplate(Inkplate.INKPLATE_1BIT) 13 | 14 | # Main function 15 | if __name__ == "__main__": 16 | 17 | # Initialize the display, needs to be called only once 18 | display.begin() 19 | 20 | # pin = display.gpioExpanderPin(gpioExpander,pin,mode) 21 | # Supported gpio expanders on Inkplate 6: 1, 2 (internal, external) 22 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 23 | # Supported pins on Inkplate 6 are listed below 24 | 25 | # Declare all the available pins as output: 26 | 27 | expander1_P1_1 = display.gpioExpanderPin(1, 9, modeOUTPUT) 28 | expander1_P1_2 = display.gpioExpanderPin(1, 10, modeOUTPUT) 29 | expander1_P1_3 = display.gpioExpanderPin(1, 11, modeOUTPUT) 30 | expander1_P1_4 = display.gpioExpanderPin(1, 12, modeOUTPUT) 31 | expander1_P1_5 = display.gpioExpanderPin(1, 13, modeOUTPUT) 32 | expander1_P1_6 = display.gpioExpanderPin(1, 14, modeOUTPUT) 33 | expander1_P1_7 = display.gpioExpanderPin(1, 15, modeOUTPUT) 34 | 35 | expander2_P0_0 = display.gpioExpanderPin(2, 0, modeOUTPUT) 36 | expander2_P0_1 = display.gpioExpanderPin(2, 1, modeOUTPUT) 37 | expander2_P0_2 = display.gpioExpanderPin(2, 2, modeOUTPUT) 38 | expander2_P0_3 = display.gpioExpanderPin(2, 3, modeOUTPUT) 39 | expander2_P0_4 = display.gpioExpanderPin(2, 4, modeOUTPUT) 40 | expander2_P0_5 = display.gpioExpanderPin(2, 5, modeOUTPUT) 41 | expander2_P0_6 = display.gpioExpanderPin(2, 6, modeOUTPUT) 42 | expander2_P0_7 = display.gpioExpanderPin(2, 7, modeOUTPUT) 43 | 44 | expander2_P1_0 = display.gpioExpanderPin(2, 8, modeOUTPUT) 45 | expander2_P1_1 = display.gpioExpanderPin(2, 9, modeOUTPUT) 46 | expander2_P1_2 = display.gpioExpanderPin(2, 10, modeOUTPUT) 47 | expander2_P1_3 = display.gpioExpanderPin(2, 11, modeOUTPUT) 48 | expander2_P1_4 = display.gpioExpanderPin(2, 12, modeOUTPUT) 49 | expander2_P1_5 = display.gpioExpanderPin(2, 13, modeOUTPUT) 50 | expander2_P1_6 = display.gpioExpanderPin(2, 14, modeOUTPUT) 51 | expander2_P1_7 = display.gpioExpanderPin(2, 15, modeOUTPUT) 52 | 53 | # Take the previously declared pin 1_5 on expander 2 and blink it 54 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 55 | while (1): 56 | expander2_P1_5.digitalWrite(1) 57 | time.sleep(0.5) 58 | expander2_P1_5.digitalWrite(0) 59 | time.sleep(0.5) 60 | # Infinite loop, this goes on forever -------------------------------------------------------------------------------- /Examples/Inkplate6/touchpads.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the touchpads 2 | # Only older models of Inkplate6 (e-Radionica Inkplate 6) have them 3 | 4 | # Include required libraries 5 | from inkplate6 import Inkplate 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Create some coordinates and a radius for drawing a circle 12 | circle_x = 400 13 | circle_y = 300 14 | circle_r = 40 15 | 16 | # Main function 17 | if __name__ == "__main__": 18 | 19 | # Initialize the display, needs to be called only once 20 | display.begin() 21 | 22 | # Clear the frame buffer 23 | display.clearDisplay() 24 | 25 | # This has to be called every time you want to update the screen 26 | # Drawing or printing text will have no effect on the display itself before you call this function 27 | display.display() 28 | 29 | # Function to show text at the top of the screen 30 | # Needs to be called every time we clear the display to re-draw the text 31 | def draw_top_text(): 32 | display.setTextSize(2) 33 | display.printText(100, 10, "TOUCHPADS EXAMPLE! 1, 3 TO MOVE CIRCLE, 2 TO RESET") 34 | 35 | # Call it 36 | draw_top_text() 37 | 38 | # Touchpads definitions 39 | touch1, touch2, touch3 = display.TOUCH1, display.TOUCH2, display.TOUCH3 40 | 41 | # Draw the initial circle for touchpad demonstration 42 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 43 | 44 | # Show everything on the display 45 | display.display() 46 | 47 | # Start infinite loop 48 | while True: 49 | # If a touchpad is pressed, move the circle and redraw everything 50 | # Touch 1 moves the circle to the left 51 | if touch1(): 52 | circle_x -= 40 53 | display.clearDisplay() 54 | draw_top_text() 55 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 56 | # Show on the display! 57 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 58 | # This makes for a faster update 59 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 60 | # This ensures the image retains it's quality 61 | display.partialUpdate() 62 | 63 | # Touch 2 will reset the position of the circle 64 | if touch2(): 65 | circle_x = 400 66 | circle_y = 300 67 | circle_r = 40 68 | display.clearDisplay() 69 | draw_top_text() 70 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 71 | display.display() # Do a full refresh also 72 | 73 | # Touch 3 will move the circle to the right 74 | if touch3(): 75 | circle_x += 40 76 | display.clearDisplay() 77 | draw_top_text() 78 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 79 | display.partialUpdate() -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/RTC.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to use the onboard RTC to preserve time across reboots 2 | 3 | # Include all the required libraries 4 | from inkplate6COLOR import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # This is how to set the RTC's time 25 | # Arguments are hour, minute, seconds 26 | display.rtcSetTime(9,39,10) 27 | # And this is the date 28 | # Arguments are weekday, day in month, month and year 29 | display.rtcSetDate(5,9,2,2024) 30 | 31 | # Show the set time 32 | print(display.rtcGetData()) 33 | 34 | # Let's wait 10 seconds 35 | time.sleep(10) 36 | 37 | # Let's see if the time has updated 38 | print(display.rtcGetData()) -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Inkplate6COLOR/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/basicCOLOR.py: -------------------------------------------------------------------------------- 1 | # This example will show you how shapes in various colors 2 | # Also, it will draw a bitmap of the Soldered logo in the middle, in blue 3 | # The update speed for this display is quite slow, so no delays in this code 4 | 5 | # Include all the required libraries 6 | from inkplate6COLOR import Inkplate 7 | from image import * 8 | 9 | # Create Inkplate object 10 | display = Inkplate() 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Let's draw some shapes! 19 | # This example will draw shapes around the upper left corner, and then rotate the screen 20 | # This creates a symmetrical-looking pattern of various shapes 21 | for r in range(4): 22 | 23 | # Sets the screen rotation 24 | display.setRotation(r) 25 | 26 | # All drawing functions 27 | # Available colors are: 28 | # Black, white, green, blue, red, yellow, orange 29 | display.drawPixel(100, 100, display.BLACK) 30 | display.drawRect(50, 50, 75, 75, display.GREEN) 31 | display.drawCircle(200, 200, 30, display.BLUE) 32 | display.fillCircle(300, 300, 30, display.RED) 33 | display.drawFastHLine(20, 100, 50, display.BLACK) 34 | display.drawFastVLine(100, 20, 50, display.ORANGE) 35 | display.drawLine(100, 100, 400, 400, display.ORANGE) 36 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 37 | display.fillRoundRect(10, 100, 100, 100, 10, display.YELLOW) 38 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 39 | 40 | # Reset the rotation 41 | display.setRotation(0) 42 | 43 | # We've drawn the pattern, now let's draw the Soldered logo in blue right in the middle 44 | display.drawBitmap(10, 160, image, 576, 100, display.BLUE) 45 | 46 | # Show on the display 47 | display.display() 48 | -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/batteryRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also the temperature from the TPS and print it on the screen 3 | 4 | # Include needed libraries 5 | from inkplate6COLOR import Inkplate 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate() 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Get the battery reading as a string 25 | battery = str(display.readBattery()) 26 | 27 | # Set text size to double from the original size, so we can see the text better 28 | display.setTextSize(2) 29 | 30 | # Print the text at coordinates 100,100 (from the upper left corner) 31 | display.printText(100, 100, "Battery voltage: " + battery + "V", display.BLACK) 32 | 33 | # Show it on the display 34 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/drawColorImage.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw a color image from buffer 2 | 3 | # Include needed libraries 4 | from inkplate6COLOR import Inkplate 5 | 6 | # Import the image 7 | # It should also be copied to Inkplate when copying other libraries 8 | # Check the README! 9 | from color_image_inkplate6COLOR import color_image_inkplate6COLOR 10 | 11 | # Create Inkplate object 12 | display = Inkplate() 13 | 14 | # Main function 15 | if __name__ == "__main__": 16 | 17 | # Initialize the display, needs to be called only once 18 | display.begin() 19 | 20 | # color_image_inkplate6color is 600x488px, draw it over the whole screen 21 | # Arguments are x start, y start, width, height, and then the image buffer 22 | display.drawColorImage(0, 0, 600, 488, color_image_inkplate6COLOR) 23 | 24 | # Show on the display 25 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from inkplate2 import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object 56 | display = Inkplate() 57 | display.begin() 58 | 59 | # Print response line by line 60 | cnt = 0 61 | for x in response.split("\n"): 62 | display.printText( 63 | 10, 20 + cnt, x.upper() 64 | ) # Default font has only upper case letters 65 | cnt += 20 66 | 67 | # Display image from buffer 68 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from inkplate6COLOR import Inkplate 7 | 8 | # Create Inkplate object 9 | display = Inkplate() 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | display.drawImageFile(0, 0, "sd/1.bmp") 34 | 35 | # You can turn off the power to the SD card to save power 36 | display.SDCardSleep() 37 | # To turn it back on, use: 38 | # display.SDCardWake() 39 | 40 | # Show the image from the buffer 41 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/gpio_expander.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the GPIO expander's pins 2 | # See below which pins are available 3 | 4 | # Include needed libraries 5 | import time 6 | from PCAL6416A import * 7 | from inkplate6COLOR import Inkplate 8 | 9 | # Create Inkplate object 10 | display = Inkplate() 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # pin = display.gpioExpanderPin(pin,mode) 19 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 20 | # Supported pins on Inkplate 6COLOR COLOR are listed below 21 | 22 | expander_P0_0 = display.gpioExpanderPin(0, modeOUTPUT) 23 | expander_P0_1 = display.gpioExpanderPin(1, modeOUTPUT) 24 | expander_P0_2 = display.gpioExpanderPin(2, modeOUTPUT) 25 | expander_P0_3 = display.gpioExpanderPin(3, modeOUTPUT) 26 | expander_P0_4 = display.gpioExpanderPin(4, modeOUTPUT) 27 | expander_P0_5 = display.gpioExpanderPin(5, modeOUTPUT) 28 | expander_P0_6 = display.gpioExpanderPin(6, modeOUTPUT) 29 | expander_P0_7 = display.gpioExpanderPin(7, modeOUTPUT) 30 | 31 | expander_P1_0 = display.gpioExpanderPin(8, modeOUTPUT) 32 | expander_P1_1 = display.gpioExpanderPin(9, modeOUTPUT) 33 | expander_P1_2 = display.gpioExpanderPin(10, modeOUTPUT) 34 | expander_P1_3 = display.gpioExpanderPin(11, modeOUTPUT) 35 | expander_P1_4 = display.gpioExpanderPin(12, modeOUTPUT) 36 | expander_P1_5 = display.gpioExpanderPin(13, modeOUTPUT) 37 | expander_P1_6 = display.gpioExpanderPin(14, modeOUTPUT) 38 | expander_P1_7 = display.gpioExpanderPin(15, modeOUTPUT) 39 | 40 | # Take the previously declared pin 1_5 and blink it 41 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 42 | while (1): 43 | expander_P1_5.digitalWrite(1) 44 | time.sleep(0.5) 45 | expander_P1_5.digitalWrite(0) 46 | time.sleep(0.5) 47 | # Infinite loop, this goes on forever 48 | -------------------------------------------------------------------------------- /Examples/Inkplate6COLOR/touchpads.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the touchpads 2 | # Only older models of Inkplate6COLOR have them 3 | 4 | # Include required libraries 5 | from inkplate6COLOR import Inkplate 6 | 7 | # Create Inkplate object 8 | display = Inkplate() 9 | 10 | # Create some coordinates and a radius for drawing a circle 11 | circle_x = 300 12 | circle_y = 200 13 | circle_r = 40 14 | 15 | # Main function 16 | if __name__ == "__main__": 17 | 18 | # Initialize the display, needs to be called only once 19 | display.begin() 20 | 21 | # Clear the frame buffer 22 | display.clearDisplay() 23 | 24 | # This has to be called every time you want to update the screen 25 | # Drawing or printing text will have no effect on the display itself before you call this function 26 | display.display() 27 | 28 | # Function to show text at the top of the screen 29 | # Needs to be called every time we clear the display to re-draw the text 30 | def draw_top_text(): 31 | display.setTextSize(2) 32 | display.printText(100, 10, "TOUCHPADS EXAMPLE! 1, 3 TO MOVE CIRCLE, 2 TO RESET") 33 | 34 | # Call it 35 | draw_top_text() 36 | 37 | # Touchpads definitions 38 | touch1, touch2, touch3 = display.TOUCH1, display.TOUCH2, display.TOUCH3 39 | 40 | # Draw the initial circle for touchpad demonstration 41 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 42 | 43 | # Show everything on the display 44 | display.display() 45 | 46 | # Start infinite loop 47 | while True: 48 | # If a touchpad is pressed, move the circle and redraw everything 49 | # Touch 1 moves the circle to the left 50 | if touch1(): 51 | circle_x -= 40 52 | display.clearDisplay() 53 | draw_top_text() 54 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 55 | # Show on the display! 56 | display.update() 57 | 58 | # Touch 2 will reset the position of the circle 59 | if touch2(): 60 | circle_x = 400 61 | circle_y = 300 62 | circle_r = 40 63 | display.clearDisplay() 64 | draw_top_text() 65 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 66 | # Show on the display! 67 | display.display() 68 | 69 | # Touch 3 will move the circle to the right 70 | if touch3(): 71 | circle_x += 40 72 | display.clearDisplay() 73 | draw_top_text() 74 | display.drawCircle(circle_x, circle_y, circle_r, display.BLACK) 75 | # Show on the display 76 | display.update() 77 | -------------------------------------------------------------------------------- /Examples/Inkplate6PLUS/RTC.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to use the onboard RTC to preserve time across reboots 2 | 3 | # Include all the required libraries 4 | from inkplate6PLUS import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # This is how to set the RTC's time 25 | # Arguments are hour, minute, seconds 26 | display.rtcSetTime(9,39,10) 27 | # And this is the date 28 | # Arguments are weekday, day in month, month and year 29 | display.rtcSetDate(5,9,2,2024) 30 | 31 | # Show the set time 32 | print(display.rtcGetData()) 33 | 34 | # Let's wait 10 seconds 35 | time.sleep(10) 36 | 37 | # Let's see if the time has updated 38 | print(display.rtcGetData()) -------------------------------------------------------------------------------- /Examples/Inkplate6PLUS/basicBW.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw basic black and white shapes 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include all the required libraries 5 | from inkplate6PLUS import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object in 1-bit mode, black and white colors only 10 | # For 2-bit grayscale, see basicGrayscale.py 11 | display = Inkplate(Inkplate.INKPLATE_1BIT) 12 | 13 | # Main function 14 | if __name__ == "__main__": 15 | 16 | # Initialize the display, needs to be called only once 17 | display.begin() 18 | 19 | # Clear the frame buffer 20 | display.clearDisplay() 21 | 22 | # This has to be called every time you want to update the screen 23 | # Drawing or printing text will have no effect on the display itself before you call this function 24 | display.display() 25 | 26 | # Let's draw some shapes! 27 | # This example will draw shapes around the upper left corner, and then rotate the screen 28 | # This creates a symmetrical-looking pattern of various shapes 29 | for r in range(4): 30 | 31 | # Sets the screen rotation 32 | display.setRotation(r) 33 | 34 | # All drawing functions 35 | display.drawPixel(100, 100, display.BLACK) 36 | display.drawRect(50, 50, 75, 75, display.BLACK) 37 | display.drawCircle(200, 200, 30, display.BLACK) 38 | display.fillCircle(300, 300, 30, display.BLACK) 39 | display.drawFastHLine(20, 100, 50, display.BLACK) 40 | display.drawFastVLine(100, 20, 50, display.BLACK) 41 | display.drawLine(100, 100, 400, 400, display.BLACK) 42 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 43 | display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK) 44 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 45 | 46 | # If it's rotation 0 or 2, also add this filled triangle 47 | if display.rotation % 2 == 0: 48 | display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK) 49 | 50 | # Show on the display! 51 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 52 | # This makes for a faster update 53 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 54 | # This ensures the image retains it's quality 55 | display.partialUpdate() 56 | 57 | # Wait 5 seconds 58 | time.sleep(5) 59 | 60 | # Reset the rotation 61 | display.setRotation(0) 62 | 63 | # We've drawn the pattern, now let's draw the Soldered logo right in the middle 64 | display.drawBitmap(406, 357, soldered_logo, 211, 44) 65 | 66 | # Show on the display 67 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6PLUS/basicGrayscale.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw different shades of gray using grayscale mode 2 | 3 | # Include needed libraries 4 | from inkplate6PLUS import Inkplate 5 | from soldered_logo import * 6 | import time 7 | 8 | # Create Inkplate object in 2-bit grayscale mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Draw pallet of posible shades 25 | # 0 being the lightest (white), 3 being the darkest 26 | display.writeFillRect(0, 0, 25, 758, 3) 27 | display.writeFillRect(25, 0, 25, 758, 2) 28 | display.writeFillRect(50, 0, 25, 758, 1) 29 | display.writeFillRect(75, 0, 25, 758, 0) 30 | 31 | # Show on the display 32 | display.display() 33 | 34 | # Wait 3 seconds 35 | time.sleep(3) 36 | 37 | # Let's draw the Soldered logo and show it on the display 38 | display.drawBitmap(184, 357, soldered_logo, 211, 44) 39 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6PLUS/batteryAndTemperatureRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also the temperature from the TPS and print it on the screen 3 | 4 | # Include needed libraries 5 | from inkplate6PLUS import Inkplate 6 | from image import * 7 | 8 | # Create Inkplate object in 1-bit mode, black and white colors only 9 | # For 2-bit grayscale, see basicGrayscale.py 10 | display = Inkplate(Inkplate.INKPLATE_1BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # Get the battery reading as a string 26 | battery = str(display.readBattery()) 27 | 28 | # Set text size to double from the original size, so we can see the text better 29 | display.setTextSize(2) 30 | 31 | # Print the text at coordinates 100,100 (from the upper left corner) 32 | display.printText(100, 100, "Battery voltage: " + battery + "V") 33 | 34 | # Show it on the display 35 | display.display() 36 | 37 | # Get the temperature reading, also as a string 38 | temperature = str(display.readTemperature()) 39 | 40 | # Print the text at coordinates 100, 150, and also add the measurement unit 41 | display.printText(100, 150, "Temperature: " + temperature + "C") 42 | 43 | # Show it on the display 44 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6PLUS/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from inkplate6PLUS import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object in 1-bit mode 56 | display = Inkplate(Inkplate.INKPLATE_1BIT) 57 | display.begin() 58 | 59 | # Set text size to double from the original size, so we can see the text better 60 | display.setTextSize(2) 61 | 62 | # Print response line by line 63 | cnt = 0 64 | for x in response.split("\n"): 65 | display.printText( 66 | 10, 20 + cnt, x.upper() 67 | ) # Default font has only upper case letters 68 | cnt += 20 69 | 70 | # Display image from buffer in full refresh 71 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6PLUS/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from inkplate6PLUS import Inkplate 7 | 8 | # Create Inkplate object in 2-bit (grayscale) mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Init Inkplate 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images or in 1-bit mode 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate6PLUS/frontlight.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to adjust the frontlight 2 | 3 | # Include required libraries 4 | from inkplate6PLUS import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit (black and white) mode 8 | display = Inkplate(Inkplate.INKPLATE_1BIT) 9 | 10 | # Main function 11 | if __name__ == "__main__": 12 | 13 | # Initialize the display, needs to be called only once 14 | display.begin() 15 | 16 | # Clear the frame buffer 17 | display.clearDisplay() 18 | 19 | # This has to be called every time you want to update the screen 20 | # Drawing or printing text will have no effect on the display itself before you call this function 21 | display.display() 22 | 23 | # Enable the frontlight 24 | display.frontlight(True) 25 | 26 | # Frontlight strength can be set from values 0 to 64 27 | # For example: 28 | display.setFrontlight(34) 29 | 30 | # Wait 3 seconds 31 | time.sleep(3) 32 | 33 | # Slowly gradually increase the frontlight and then decrease it, infinitely 34 | while(True): 35 | # First, increase the brightness gradually 36 | for i in range(0, 60): 37 | display.setFrontlight(i) 38 | time.sleep(0.5) # Wait for 500ms 39 | 40 | # Then, decrease 41 | for i in range(60, 0): 42 | display.setFrontlight(i) 43 | time.sleep(0.5) # Wait for 500ms -------------------------------------------------------------------------------- /Examples/Inkplate6PLUS/touchscreen.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the touchscreen on Inkplate6PLUS! 2 | 3 | # Include needed libraries 4 | from inkplate6PLUS import Inkplate 5 | 6 | # Create Inkplate object in 1-bit mode, black and white colors only 7 | display = Inkplate(Inkplate.INKPLATE_1BIT) 8 | 9 | # Main function 10 | if __name__ == "__main__": 11 | 12 | # Initialize the display, needs to be called only once 13 | display.begin() 14 | 15 | # Clear the frame buffer 16 | display.clearDisplay() 17 | 18 | # This has to be called every time you want to update the screen 19 | # Drawing or printing text will have no effect on the display itself before you call this function 20 | display.display() 21 | 22 | # Initialize the touchscreen 23 | display.tsInit(1) 24 | 25 | # Draw a rectangle right in the middle of the screen and show it 26 | display.drawRect(450, 350, 100, 100, display.BLACK) 27 | display.display() 28 | 29 | # Every time the user touches that rectangle, print a message 30 | # The messags get printed to the terminal where the script was ran from 31 | # Create the variable which counts how many times the rectangle was touched 32 | counter = 0 33 | while True: 34 | # If a touch on the square was detected 35 | if(display.touchInArea(450, 350, 100, 100)): 36 | # Increment the counter and print a message 37 | counter += 1 38 | print("Touch detected! Touch #: "+str(counter)) -------------------------------------------------------------------------------- /Examples/Inkplate7/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Inkplate7/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Inkplate7/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Inkplate7/basicBWR.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw shapes and text in black, white and red 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include all the required libraries 5 | from inkplate7 import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object 10 | display = Inkplate() 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # Let's draw some shapes! 26 | # This example will draw shapes around the upper left corner, and then rotate the screen 27 | # This creates a symmetrical-looking pattern of various shapes 28 | for r in range(4): 29 | 30 | # Sets the screen rotation 31 | display.setRotation(r) 32 | 33 | # All drawing functions 34 | # Draw some of the elements in red so we can see the color 35 | display.drawPixel(100, 100, display.BLACK) 36 | display.drawRect(50, 50, 75, 75, display.RED) 37 | display.drawCircle(200, 200, 30, display.RED) 38 | display.fillCircle(300, 300, 30, display.BLACK) 39 | display.drawFastHLine(20, 100, 50, display.BLACK) 40 | display.drawFastVLine(100, 20, 50, display.BLACK) 41 | display.drawLine(100, 100, 400, 400, display.BLACK) 42 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 43 | display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK) 44 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 45 | 46 | # If it's rotation 0 or 2, also add this filled triangle 47 | if display.rotation % 2 == 0: 48 | display.fillTriangle(500, 101, 400, 150, 400, 100, display.RED) 49 | 50 | # Show on the display! 51 | # This function must be called in order for the display to update 52 | display.display() 53 | 54 | # Wait 5 seconds 55 | time.sleep(5) 56 | 57 | # Reset the rotation 58 | display.setRotation(0) 59 | 60 | # Let's draw the Soldered logo right in the middle 61 | # First, fill the background of the image white 62 | display.fillRect(214, 170, 211, 44, display.WHITE) 63 | # Now, draw the logo 64 | display.drawBitmap(214, 170, soldered_logo, 211, 44, display.RED) 65 | 66 | # Show on the display 67 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate7/batteryRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also print it on the screen 3 | 4 | # Include needed libraries 5 | from inkplate7 import Inkplate 6 | import time 7 | 8 | # Create Inkplate object 9 | display = Inkplate() 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Get the battery reading as a string 25 | battery = str(display.readBattery()) 26 | 27 | # Set text size to double from the original size, so we can see the text better 28 | display.setTextSize(2) 29 | 30 | # Print the text at coordinates 100,100 (from the upper left corner) 31 | display.printText(100, 100, "Battery voltage: " + battery + "V") 32 | 33 | # Show it on the display 34 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate7/drawColorImage.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw a color image (black, white, red) 2 | # The pixel format is four pixels per byte, each pixel two bits 3 | # 00 is Black 4 | # 01 is White 5 | # 10 is Red 6 | # For simple conversion use the Soldered Image Converter 7 | 8 | # Include needed libraries 9 | from inkplate7 import Inkplate 10 | 11 | # Import the image 12 | # It should also be copied to Inkplate when copying other libraries 13 | # Check the README! 14 | from color_image_inkplate7 import color_image_inkplate7 15 | 16 | # Create Inkplate object 17 | display = Inkplate() 18 | 19 | # Main function 20 | if __name__ == "__main__": 21 | 22 | # Initialize the display, needs to be called only once 23 | display.begin() 24 | 25 | # color_image_inkplate2 is 212x104px, draw it over the whole screen 26 | # Arguments are x start, y start, width, height, and then the image buffer 27 | display.drawColorImage(0, 0, 212, 104, color_image_inkplate7) 28 | 29 | # Show it on the display 30 | display.display() 31 | -------------------------------------------------------------------------------- /Examples/Inkplate7/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from inkplate7 import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object 56 | display = Inkplate() 57 | display.begin() 58 | 59 | # Set text size to double from the original size, so we can see the text better 60 | display.setTextSize(2) 61 | 62 | # Print response line by line 63 | cnt = 0 64 | for x in response.split("\n"): 65 | display.printText( 66 | 10, 20 + cnt, x.upper() 67 | ) # Default font has only upper case letters 68 | cnt += 20 69 | 70 | # Display image from buffer 71 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate7/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from inkplate7 import Inkplate 7 | 8 | # Create Inkplate object 9 | display = Inkplate() 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Inkplate7/gpio_expander.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the GPIO expander's pins 2 | # See below which pins are available 3 | 4 | # Include needed libraries 5 | import time 6 | from PCAL6416A import * 7 | from soldered_inkplate7 import Inkplate 8 | 9 | # Create Inkplate object 10 | display = Inkplate() 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # pin = display.gpioExpanderPin(gpioExpander,pin,mode) 19 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 20 | # Supported pins on Soldered Inkplate 7 are listed below 21 | 22 | # Declare all the available pins as output: 23 | 24 | expander_P0_0 = display.gpioExpanderPin(0, modeOUTPUT) 25 | expander_P0_1 = display.gpioExpanderPin(1, modeOUTPUT) 26 | expander_P0_2 = display.gpioExpanderPin(2, modeOUTPUT) 27 | expander_P0_3 = display.gpioExpanderPin(3, modeOUTPUT) 28 | expander_P0_4 = display.gpioExpanderPin(4, modeOUTPUT) 29 | expander_P0_5 = display.gpioExpanderPin(5, modeOUTPUT) 30 | expander_P0_6 = display.gpioExpanderPin(6, modeOUTPUT) 31 | expander_P0_7 = display.gpioExpanderPin(7, modeOUTPUT) 32 | 33 | expander_P1_0 = display.gpioExpanderPin(8, modeOUTPUT) 34 | expander_P1_1 = display.gpioExpanderPin(9, modeOUTPUT) 35 | expander_P1_2 = display.gpioExpanderPin(10, modeOUTPUT) 36 | expander_P1_3 = display.gpioExpanderPin(11, modeOUTPUT) 37 | expander_P1_4 = display.gpioExpanderPin(12, modeOUTPUT) 38 | expander_P1_5 = display.gpioExpanderPin(13, modeOUTPUT) 39 | expander_P1_6 = display.gpioExpanderPin(14, modeOUTPUT) 40 | expander_P1_7 = display.gpioExpanderPin(15, modeOUTPUT) 41 | 42 | # Take the previously declared pin 1_5 and blink it 43 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 44 | while (1): 45 | expander_P1_5.digitalWrite(1) 46 | time.sleep(0.5) 47 | expander_P1_5.digitalWrite(0) 48 | time.sleep(0.5) 49 | # Infinite loop, this goes on forever -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/RTC.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to use the onboard RTC to preserve time across reboots 2 | 3 | # Include all the required libraries 4 | from soldered_inkplate10 import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # This is how to set the RTC's time 25 | # Arguments are hour, minute, seconds 26 | display.rtcSetTime(9,39,10) 27 | # And this is the date 28 | # Arguments are weekday, day in month, month and year 29 | display.rtcSetDate(5,9,2,2024) 30 | 31 | # Show the set time 32 | print(display.rtcGetData()) 33 | 34 | # Let's wait 10 seconds 35 | time.sleep(10) 36 | 37 | # Let's see if the time has updated 38 | print(display.rtcGetData()) -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Soldered_Inkplate10/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/basicBW.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw basic black and white shapes 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include all the required libraries 5 | from soldered_inkplate10 import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object in 1-bit mode, black and white colors only 10 | # For 2-bit grayscale, see basicGrayscale.py 11 | display = Inkplate(Inkplate.INKPLATE_1BIT) 12 | 13 | # Main function 14 | if __name__ == "__main__": 15 | 16 | # Initialize the display, needs to be called only once 17 | display.begin() 18 | 19 | # Clear the frame buffer 20 | display.clearDisplay() 21 | 22 | # This has to be called every time you want to update the screen 23 | # Drawing or printing text will have no effect on the display itself before you call this function 24 | display.display() 25 | 26 | # Let's draw some shapes! 27 | # This example will draw shapes around the upper left corner, and then rotate the screen 28 | # This creates a symmetrical-looking pattern of various shapes 29 | for r in range(4): 30 | 31 | # Sets the screen rotation 32 | display.setRotation(r) 33 | 34 | # All drawing functions 35 | display.drawPixel(100, 100, display.BLACK) 36 | display.drawRect(50, 50, 75, 75, display.BLACK) 37 | display.drawCircle(200, 200, 30, display.BLACK) 38 | display.fillCircle(300, 300, 30, display.BLACK) 39 | display.drawFastHLine(20, 100, 50, display.BLACK) 40 | display.drawFastVLine(100, 20, 50, display.BLACK) 41 | display.drawLine(100, 100, 400, 400, display.BLACK) 42 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 43 | display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK) 44 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 45 | 46 | # If it's rotation 0 or 2, also add this filled triangle 47 | if display.rotation % 2 == 0: 48 | display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK) 49 | 50 | # Show on the display! 51 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 52 | # This makes for a faster update 53 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 54 | # This ensures the image retains it's quality 55 | display.partialUpdate() 56 | 57 | # Wait 5 seconds 58 | time.sleep(5) 59 | 60 | # Reset the rotation 61 | display.setRotation(0) 62 | 63 | # We've drawn the pattern, now let's draw the Soldered logo right in the middle 64 | display.drawBitmap(494, 391, soldered_logo, 211, 44) 65 | 66 | # Show on the display, this time with a full update 67 | display.display() 68 | -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/basicGrayscale.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw different shades of gray using grayscale mode 2 | 3 | # Include needed libraries 4 | from soldered_inkplate10 import Inkplate 5 | from soldered_logo import * 6 | import time 7 | 8 | # Create Inkplate object in 2-bit grayscale mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Draw pallet of posible shades 25 | # 0 being the lightest (white), 3 being the darkest 26 | display.writeFillRect(0, 0, 25, 825, 3) 27 | display.writeFillRect(25, 0, 25, 825, 2) 28 | display.writeFillRect(50, 0, 25, 825, 1) 29 | display.writeFillRect(75, 0, 25, 825, 0) 30 | 31 | # Show on the display 32 | display.display() 33 | 34 | # Wait 3 seconds 35 | time.sleep(3) 36 | 37 | # Let's draw the Soldered logo and show it on the display 38 | display.drawBitmap(248, 391, soldered_logo, 211, 44) 39 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/batteryAndTemperatureRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also the temperature from the TPS and print it on the screen 3 | 4 | # Include needed libraries 5 | from soldered_inkplate10 import Inkplate 6 | import time 7 | 8 | # Create Inkplate object in 1-bit mode, black and white colors only 9 | # For 2-bit grayscale, see basicGrayscale.py 10 | display = Inkplate(Inkplate.INKPLATE_1BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Get the battery reading as a string 25 | battery = str(display.readBattery()) 26 | 27 | # Set text size to double from the original size, so we can see the text better 28 | display.setTextSize(2) 29 | 30 | # Print the text at coordinates 100,100 (from the upper left corner) 31 | display.printText(100, 100, "Battery voltage: " + battery + "V") 32 | 33 | # Show it on the display 34 | display.display() 35 | 36 | # Wait 5 seconds 37 | time.sleep(5) 38 | 39 | # Get the temperature reading, also as a string 40 | temperature = str(display.readTemperature()) 41 | 42 | # Print the text at coordinates 100, 150, and also add the measurement unit 43 | display.printText(100, 150, "Temperature: " + temperature + "C") 44 | 45 | # Show it on the display 46 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/drawGrayscaleImage.py: -------------------------------------------------------------------------------- 1 | # This example shows how to draw a grayscale image from the SD card 2 | # Copy the image from Sd_card_example_files and place it on the microSD card 3 | # NOTE: This takes quite a while as MicroPython can be a bit slow 4 | 5 | # Include needed libraries 6 | from soldered_inkplate10 import Inkplate 7 | import os, time 8 | 9 | # Init display in 2bit mode, important 10 | display = Inkplate(Inkplate.INKPLATE_2BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # SD Card must be initialised with this function 26 | display.initSDCard() 27 | 28 | # Wait one second so we're totally sure it's initialized 29 | time.sleep(1) 30 | 31 | # Wake the SD (power ON) 32 | display.SDCardWake() 33 | 34 | # Draw image in grayscale and display it 35 | # Also print a message before and after 36 | print("Starting to draw image from file!") 37 | display.drawImageFile(0, 0, "sd/1.bmp", False) 38 | display.display() 39 | print("Finished drawing image from file!") 40 | 41 | # Put the SD card back to sleep to save power 42 | display.SDCardSleep() 43 | # To turn it back on, use: 44 | # display.SDCardWake() 45 | -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from soldered_inkplate10 import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object in 1-bit mode 56 | display = Inkplate(Inkplate.INKPLATE_1BIT) 57 | display.begin() 58 | 59 | # Set text size to double from the original size, so we can see the text better 60 | display.setTextSize(2) 61 | 62 | # Print response line by line 63 | cnt = 0 64 | for x in response.split("\n"): 65 | display.printText( 66 | 10, 20 + cnt, x.upper() 67 | ) # Default font has only upper case letters 68 | cnt += 20 69 | 70 | # Display image from buffer in full refresh 71 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from soldered_inkplate10 import Inkplate 7 | 8 | # Create Inkplate object in 2-bit (grayscale) mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Init Inkplate 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images or in 1-bit mode 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate10/gpio_expander.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the GPIO expander's pins 2 | # Soldered Inkplate10 has an internal and external GPIO expander 3 | # See below which pins are available 4 | 5 | # Include needed libraries 6 | import time 7 | from PCAL6416A import * 8 | from soldered_inkplate10 import Inkplate 9 | 10 | # Create Inkplate object in 1-bit mode, black and white colors only 11 | # For 2-bit grayscale, see basicGrayscale.py 12 | display = Inkplate(Inkplate.INKPLATE_1BIT) 13 | 14 | # Main function 15 | if __name__ == "__main__": 16 | # Initialize the display, needs to be called only once 17 | display.begin() 18 | 19 | # pin = display.gpioExpanderPin(gpioExpander,pin,mode) 20 | # Supported gpio expanders on Soldered Inkplate 10: 1, 2 (internal, external) 21 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 22 | # Supported pins on Soldered Inkplate 10 are listed below 23 | 24 | # Declare all the available pins as output: 25 | 26 | expander1_P1_1 = display.gpioExpanderPin(1, 9, modeOUTPUT) 27 | expander1_P1_2 = display.gpioExpanderPin(1, 10, modeOUTPUT) 28 | expander1_P1_3 = display.gpioExpanderPin(1, 11, modeOUTPUT) 29 | expander1_P1_4 = display.gpioExpanderPin(1, 12, modeOUTPUT) 30 | expander1_P1_5 = display.gpioExpanderPin(1, 13, modeOUTPUT) 31 | expander1_P1_6 = display.gpioExpanderPin(1, 14, modeOUTPUT) 32 | expander1_P1_7 = display.gpioExpanderPin(1, 15, modeOUTPUT) 33 | 34 | expander2_P0_0 = display.gpioExpanderPin(2, 0, modeOUTPUT) 35 | expander2_P0_1 = display.gpioExpanderPin(2, 1, modeOUTPUT) 36 | expander2_P0_2 = display.gpioExpanderPin(2, 2, modeOUTPUT) 37 | expander2_P0_3 = display.gpioExpanderPin(2, 3, modeOUTPUT) 38 | expander2_P0_4 = display.gpioExpanderPin(2, 4, modeOUTPUT) 39 | expander2_P0_5 = display.gpioExpanderPin(2, 5, modeOUTPUT) 40 | expander2_P0_6 = display.gpioExpanderPin(2, 6, modeOUTPUT) 41 | expander2_P0_7 = display.gpioExpanderPin(2, 7, modeOUTPUT) 42 | 43 | expander2_P1_0 = display.gpioExpanderPin(2, 8, modeOUTPUT) 44 | expander2_P1_1 = display.gpioExpanderPin(2, 9, modeOUTPUT) 45 | expander2_P1_2 = display.gpioExpanderPin(2, 10, modeOUTPUT) 46 | expander2_P1_3 = display.gpioExpanderPin(2, 11, modeOUTPUT) 47 | expander2_P1_4 = display.gpioExpanderPin(2, 12, modeOUTPUT) 48 | expander2_P1_5 = display.gpioExpanderPin(2, 13, modeOUTPUT) 49 | expander2_P1_6 = display.gpioExpanderPin(2, 14, modeOUTPUT) 50 | expander2_P1_7 = display.gpioExpanderPin(2, 15, modeOUTPUT) 51 | 52 | # Take the previously declared pin 1_5 on expander 2 and blink it 53 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 54 | while (1): 55 | expander2_P1_5.digitalWrite(1) 56 | time.sleep(0.5) 57 | expander2_P1_5.digitalWrite(0) 58 | time.sleep(0.5) 59 | # Infinite loop, this goes on forever -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/RTC.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to use the onboard RTC to preserve time across reboots 2 | 3 | # Include all the required libraries 4 | from soldered_inkplate6 import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # This is how to set the RTC's time 25 | # Arguments are hour, minute, seconds 26 | display.rtcSetTime(9,39,10) 27 | # And this is the date 28 | # Arguments are weekday, day in month, month and year 29 | display.rtcSetDate(5,9,2,2024) 30 | 31 | # Show the set time 32 | print(display.rtcGetData()) 33 | 34 | # Let's wait 10 seconds 35 | time.sleep(10) 36 | 37 | # Let's see if the time has updated 38 | print(display.rtcGetData()) -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Soldered_Inkplate6/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/basicBW.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw basic black and white shapes 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include all the required libraries 5 | from soldered_inkplate6 import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object in 1-bit mode, black and white colors only 10 | # For 2-bit grayscale, see basicGrayscale.py 11 | display = Inkplate(Inkplate.INKPLATE_1BIT) 12 | 13 | # Main function 14 | if __name__ == "__main__": 15 | 16 | # Initialize the display, needs to be called only once 17 | display.begin() 18 | 19 | # Clear the frame buffer 20 | display.clearDisplay() 21 | 22 | # This has to be called every time you want to update the screen 23 | # Drawing or printing text will have no effect on the display itself before you call this function 24 | display.display() 25 | 26 | # Let's draw some shapes! 27 | # This example will draw shapes around the upper left corner, and then rotate the screen 28 | # This creates a symmetrical-looking pattern of various shapes 29 | for r in range(4): 30 | 31 | # Sets the screen rotation 32 | display.setRotation(r) 33 | 34 | # All the drawing functions 35 | display.drawPixel(100, 100, display.BLACK) 36 | display.drawRect(50, 50, 75, 75, display.BLACK) 37 | display.drawCircle(200, 200, 30, display.BLACK) 38 | display.fillCircle(300, 300, 30, display.BLACK) 39 | display.drawFastHLine(20, 100, 50, display.BLACK) 40 | display.drawFastVLine(100, 20, 50, display.BLACK) 41 | display.drawLine(100, 100, 400, 400, display.BLACK) 42 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 43 | display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK) 44 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 45 | 46 | # If it's rotation 0 or 2, also add this filled triangle 47 | if display.rotation % 2 == 0: 48 | display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK) 49 | 50 | # Show on the display! 51 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 52 | # This makes for a faster update 53 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 54 | # This ensures the image retains it's quality 55 | display.partialUpdate() 56 | 57 | # Wait 5 seconds 58 | time.sleep(5) 59 | 60 | # Reset the rotation 61 | display.setRotation(0) 62 | 63 | # We've drawn the pattern, now let's draw the Soldered logo right in the middle 64 | display.drawBitmap(294, 20, soldered_logo, 211, 44) 65 | 66 | # Show on the display 67 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/basicGrayscale.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw different shades of gray using grayscale mode 2 | 3 | # Include needed libraries 4 | from soldered_inkplate6 import Inkplate 5 | from soldered_logo import * 6 | import time 7 | 8 | # Create Inkplate object in 2-bit grayscale mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Draw pallet of posible shades 25 | # 0 being the lightest (white), 3 being the darkest 26 | display.writeFillRect(0, 0, 25, 600, 3) 27 | display.writeFillRect(25, 0, 25, 600, 2) 28 | display.writeFillRect(50, 0, 25, 600, 1) 29 | display.writeFillRect(75, 0, 25, 600, 0) 30 | 31 | # Show on the display 32 | display.display() 33 | 34 | # Wait 3 seconds 35 | time.sleep(3) 36 | 37 | # Let's draw the Soldered logo and show it on the display 38 | display.drawBitmap(294, 278, soldered_logo, 211, 44) 39 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/batteryAndTemperatureRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also the temperature from the TPS and print it on the screen 3 | 4 | # Include needed libraries 5 | from soldered_inkplate6 import Inkplate 6 | import time 7 | 8 | # Create Inkplate object in 1-bit mode, black and white colors only 9 | # For 2-bit grayscale, see basicGrayscale.py 10 | display = Inkplate(Inkplate.INKPLATE_1BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # Get the battery reading as a string 26 | battery = str(display.readBattery()) 27 | 28 | # Set text size to double from the original size, so we can see the text better 29 | display.setTextSize(2) 30 | 31 | # Print the text at coordinates 100,100 (from the upper left corner) 32 | display.printText(100, 100, "Battery voltage: " + battery + "V") 33 | 34 | # Show it on the display 35 | display.display() 36 | 37 | # Wait 5 seconds 38 | time.sleep(5) 39 | 40 | # Get the temperature reading, also as a string 41 | temperature = str(display.readTemperature()) 42 | 43 | # Print the text at coordinates 100, 150, and also add the measurement unit 44 | display.printText(100, 150, "Temperature: " + temperature + "C") 45 | 46 | # Show it on the display 47 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/drawGrayscaleImage.py: -------------------------------------------------------------------------------- 1 | # This example shows how to draw a grayscale image from the SD card 2 | # Copy the image from Sd_card_example_files and place it on the microSD card 3 | # NOTE: This takes quite a while as MicroPython can be a bit slow 4 | 5 | # Include needed libraries 6 | from soldered_inkplate6 import Inkplate 7 | import os, time 8 | 9 | # Init display in 2bit mode, important 10 | display = Inkplate(Inkplate.INKPLATE_2BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # SD Card must be initialised with this function 26 | display.initSDCard() 27 | 28 | # Wait one second so we're totally sure it's initialized 29 | time.sleep(1) 30 | 31 | # Wake the SD (power ON) 32 | display.SDCardWake() 33 | 34 | # Draw image in grayscale and display it 35 | # Also print a message before and after 36 | print("Starting to draw image from file!") 37 | display.drawImageFile(0, 0, "sd/1.bmp", False) 38 | display.display() 39 | print("Finished drawing image from file!") 40 | 41 | # Put the SD card back to sleep to save power 42 | display.SDCardSleep() 43 | # To turn it back on, use: 44 | # display.SDCardWake() 45 | -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from soldered_inkplate6 import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object in 1-bit mode 56 | display = Inkplate(Inkplate.INKPLATE_1BIT) 57 | display.begin() 58 | 59 | # Set text size to double from the original size, so we can see the text better 60 | display.setTextSize(2) 61 | 62 | # Print response line by line 63 | cnt = 0 64 | for x in response.split("\n"): 65 | display.printText( 66 | 10, 20 + cnt, x.upper() 67 | ) # Default font has only upper case letters 68 | cnt += 20 69 | 70 | # Display image from buffer in full refresh 71 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from soldered_inkplate6 import Inkplate 7 | 8 | # Create Inkplate object in 2-bit (grayscale) mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images or in 1-bit mode 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6/gpio_expander.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the GPIO expander's pins 2 | # Soldered Inkplate6 has an internal and external GPIO expander 3 | # See below which pins are available 4 | 5 | # Include needed libraries 6 | import time 7 | from PCAL6416A import * 8 | from soldered_inkplate6 import Inkplate 9 | 10 | # Create Inkplate object in 1-bit mode, black and white colors only 11 | # For 2-bit grayscale, see basicGrayscale.py 12 | display = Inkplate(Inkplate.INKPLATE_1BIT) 13 | 14 | # Main function 15 | if __name__ == "__main__": 16 | 17 | # Initialize the display, needs to be called only once 18 | display.begin() 19 | 20 | # pin = display.gpioExpanderPin(gpioExpander,pin,mode) 21 | # Supported gpio expanders on Soldered Inkplate 6: 1, 2 (internal, external) 22 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 23 | # Supported pins on Soldered Inkplate 6 are listed below 24 | 25 | # Declare all the available pins as output: 26 | 27 | expander1_P1_1 = display.gpioExpanderPin(1, 9, modeOUTPUT) 28 | expander1_P1_2 = display.gpioExpanderPin(1, 10, modeOUTPUT) 29 | expander1_P1_3 = display.gpioExpanderPin(1, 11, modeOUTPUT) 30 | expander1_P1_4 = display.gpioExpanderPin(1, 12, modeOUTPUT) 31 | expander1_P1_5 = display.gpioExpanderPin(1, 13, modeOUTPUT) 32 | expander1_P1_6 = display.gpioExpanderPin(1, 14, modeOUTPUT) 33 | expander1_P1_7 = display.gpioExpanderPin(1, 15, modeOUTPUT) 34 | 35 | expander2_P0_0 = display.gpioExpanderPin(2, 0, modeOUTPUT) 36 | expander2_P0_1 = display.gpioExpanderPin(2, 1, modeOUTPUT) 37 | expander2_P0_2 = display.gpioExpanderPin(2, 2, modeOUTPUT) 38 | expander2_P0_3 = display.gpioExpanderPin(2, 3, modeOUTPUT) 39 | expander2_P0_4 = display.gpioExpanderPin(2, 4, modeOUTPUT) 40 | expander2_P0_5 = display.gpioExpanderPin(2, 5, modeOUTPUT) 41 | expander2_P0_6 = display.gpioExpanderPin(2, 6, modeOUTPUT) 42 | expander2_P0_7 = display.gpioExpanderPin(2, 7, modeOUTPUT) 43 | 44 | expander2_P1_0 = display.gpioExpanderPin(2, 8, modeOUTPUT) 45 | expander2_P1_1 = display.gpioExpanderPin(2, 9, modeOUTPUT) 46 | expander2_P1_2 = display.gpioExpanderPin(2, 10, modeOUTPUT) 47 | expander2_P1_3 = display.gpioExpanderPin(2, 11, modeOUTPUT) 48 | expander2_P1_4 = display.gpioExpanderPin(2, 12, modeOUTPUT) 49 | expander2_P1_5 = display.gpioExpanderPin(2, 13, modeOUTPUT) 50 | expander2_P1_6 = display.gpioExpanderPin(2, 14, modeOUTPUT) 51 | expander2_P1_7 = display.gpioExpanderPin(2, 15, modeOUTPUT) 52 | 53 | # Take the previously declared pin 1_5 on expander 2 and blink it 54 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 55 | while (1): 56 | expander2_P1_5.digitalWrite(1) 57 | time.sleep(0.5) 58 | expander2_P1_5.digitalWrite(0) 59 | time.sleep(0.5) 60 | # Infinite loop, this goes on forever -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/RTC.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to use the onboard RTC to preserve time across reboots 2 | 3 | # Include all the required libraries 4 | from soldered_inkplate6PLUS import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit mode, black and white colors only 8 | # For 2-bit grayscale, see basicGrayscale.py 9 | display = Inkplate(Inkplate.INKPLATE_1BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # This is how to set the RTC's time 25 | # Arguments are hour, minute, seconds 26 | display.rtcSetTime(9,39,10) 27 | # And this is the date 28 | # Arguments are weekday, day in month, month and year 29 | display.rtcSetDate(5,9,2,2024) 30 | 31 | # Show the set time 32 | print(display.rtcGetData()) 33 | 34 | # Let's wait 10 seconds 35 | time.sleep(10) 36 | 37 | # Let's see if the time has updated 38 | print(display.rtcGetData()) -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/Sd_card_example_files/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/Examples/Soldered_Inkplate6PLUS/Sd_card_example_files/1.bmp -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/Sd_card_example_files/text.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum. Donec in efficitur leo, nec vehicula elit. 2 | 3 | Suspendisse potenti. Nullam quis risus eget urna mollis ornare vel eu leo. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. 4 | 5 | Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Pellentesque in ipsum id orci porta dapibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae. 6 | 7 | Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Vivamus suscipit tortor eget felis porttitor volutpat. Cras ultricies ligula sed magna dictum porta. 8 | 9 | Quisque velit nisi, pretium ut lacinia in, elementum id enim. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Sed porttitor lectus nibh, et malesuada fames ac turpis egestas. -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/basicBW.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw basic black and white shapes 2 | # Also, it will draw a bitmap of the Soldered logo in the middle 3 | 4 | # Include all the required libraries 5 | from soldered_inkplate6PLUS import Inkplate 6 | from soldered_logo import * 7 | import time 8 | 9 | # Create Inkplate object in 1-bit mode, black and white colors only 10 | # For 2-bit grayscale, see basicGrayscale.py 11 | display = Inkplate(Inkplate.INKPLATE_1BIT) 12 | 13 | # Main function 14 | if __name__ == "__main__": 15 | 16 | # Initialize the display, needs to be called only once 17 | display.begin() 18 | 19 | # Clear the frame buffer 20 | display.clearDisplay() 21 | 22 | # This has to be called every time you want to update the screen 23 | # Drawing or printing text will have no effect on the display itself before you call this function 24 | display.display() 25 | 26 | # Let's draw some shapes! 27 | # This example will draw shapes around the upper left corner, and then rotate the screen 28 | # This creates a symmetrical-looking pattern of various shapes 29 | for r in range(4): 30 | 31 | # Sets the screen rotation 32 | display.setRotation(r) 33 | 34 | # All drawing functions 35 | display.drawPixel(100, 100, display.BLACK) 36 | display.drawRect(50, 50, 75, 75, display.BLACK) 37 | display.drawCircle(200, 200, 30, display.BLACK) 38 | display.fillCircle(300, 300, 30, display.BLACK) 39 | display.drawFastHLine(20, 100, 50, display.BLACK) 40 | display.drawFastVLine(100, 20, 50, display.BLACK) 41 | display.drawLine(100, 100, 400, 400, display.BLACK) 42 | display.drawRoundRect(100, 10, 100, 100, 10, display.BLACK) 43 | display.fillRoundRect(10, 100, 100, 100, 10, display.BLACK) 44 | display.drawTriangle(300, 100, 400, 150, 400, 100, display.BLACK) 45 | 46 | # If it's rotation 0 or 2, also add this filled triangle 47 | if display.rotation % 2 == 0: 48 | display.fillTriangle(500, 101, 400, 150, 400, 100, display.BLACK) 49 | 50 | # Show on the display! 51 | # Use display.partialUpdate instead of display.display() to draw only updated pixels 52 | # This makes for a faster update 53 | # IMPORTANT: the display should be fully updated every ~10 partialUpdates with display.display() 54 | # This ensures the image retains it's quality 55 | display.partialUpdate() 56 | 57 | # Wait 5 seconds 58 | time.sleep(5) 59 | 60 | # Reset the rotation 61 | display.setRotation(0) 62 | 63 | # We've drawn the pattern, now let's draw the Soldered logo right in the middle 64 | display.drawBitmap(406, 357, soldered_logo, 211, 44) 65 | 66 | # Show on the display 67 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/basicGrayscale.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to draw different shades of gray using grayscale mode 2 | 3 | # Include needed libraries 4 | from soldered_inkplate6PLUS import Inkplate 5 | from soldered_logo import * 6 | import time 7 | 8 | # Create Inkplate object in 2-bit grayscale mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Initialize the display, needs to be called only once 15 | display.begin() 16 | 17 | # Clear the frame buffer 18 | display.clearDisplay() 19 | 20 | # This has to be called every time you want to update the screen 21 | # Drawing or printing text will have no effect on the display itself before you call this function 22 | display.display() 23 | 24 | # Draw pallet of posible shades 25 | # 0 being the lightest (white), 3 being the darkest 26 | display.writeFillRect(0, 0, 25, 758, 3) 27 | display.writeFillRect(25, 0, 25, 758, 2) 28 | display.writeFillRect(50, 0, 25, 758, 1) 29 | display.writeFillRect(75, 0, 25, 758, 0) 30 | 31 | # Show on the display 32 | display.display() 33 | 34 | # Wait 3 seconds 35 | time.sleep(3) 36 | 37 | # Let's draw the Soldered logo and show it on the display 38 | display.drawBitmap(184, 357, soldered_logo, 211, 44) 39 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/batteryAndTemperatureRead.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to read the voltage of the battery 2 | # and also the temperature from the TPS and print it on the screen 3 | 4 | # Include needed libraries 5 | from soldered_inkplate6PLUS import Inkplate 6 | from image import * 7 | 8 | # Create Inkplate object in 1-bit mode, black and white colors only 9 | # For 2-bit grayscale, see basicGrayscale.py 10 | display = Inkplate(Inkplate.INKPLATE_1BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # Get the battery reading as a string 26 | battery = str(display.readBattery()) 27 | 28 | # Set text size to double from the original size, so we can see the text better 29 | display.setTextSize(2) 30 | 31 | # Print the text at coordinates 100,100 (from the upper left corner) 32 | display.printText(100, 100, "Battery voltage: " + battery + "V") 33 | 34 | # Show it on the display 35 | display.display() 36 | 37 | # Get the temperature reading, also as a string 38 | temperature = str(display.readTemperature()) 39 | 40 | # Print the text at coordinates 100, 150, and also add the measurement unit 41 | display.printText(100, 150, "Temperature: " + temperature + "C") 42 | 43 | # Show it on the display 44 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/drawGrayscaleImage.py: -------------------------------------------------------------------------------- 1 | # This example shows how to draw a grayscale image from the SD card 2 | # Copy the image from Sd_card_example_files and place it on the microSD card 3 | # NOTE: This takes quite a while as MicroPython can be a bit slow 4 | 5 | # Include needed libraries 6 | from soldered_inkplate6PLUS import Inkplate 7 | import os, time 8 | 9 | # Init display in 2bit mode, important 10 | display = Inkplate(Inkplate.INKPLATE_2BIT) 11 | 12 | # Main function 13 | if __name__ == "__main__": 14 | 15 | # Initialize the display, needs to be called only once 16 | display.begin() 17 | 18 | # Clear the frame buffer 19 | display.clearDisplay() 20 | 21 | # This has to be called every time you want to update the screen 22 | # Drawing or printing text will have no effect on the display itself before you call this function 23 | display.display() 24 | 25 | # SD Card must be initialised with this function 26 | display.initSDCard() 27 | 28 | # Wait one second so we're totally sure it's initialized 29 | time.sleep(1) 30 | 31 | # Wake the SD (power ON) 32 | display.SDCardWake() 33 | 34 | # Draw image in grayscale and display it 35 | # Also print a message before and after 36 | print("Starting to draw image from file!") 37 | display.drawImageFile(0, 0, "sd/1.bmp", False) 38 | display.display() 39 | print("Finished drawing image from file!") 40 | 41 | # Put the SD card back to sleep to save power 42 | display.SDCardSleep() 43 | # To turn it back on, use: 44 | # display.SDCardWake() 45 | -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/exampleNetwork.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to connect to WiFi 2 | # get data from the internet and then print it 3 | 4 | # Include needed libraries 5 | import network 6 | import time 7 | from soldered_inkplate6PLUS import Inkplate 8 | 9 | # Enter your WiFi credentials here 10 | ssid = "" 11 | password = "" 12 | 13 | # Function which connects to WiFi 14 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html 15 | def do_connect(): 16 | import network 17 | sta_if = network.WLAN(network.STA_IF) 18 | if not sta_if.isconnected(): 19 | print("connecting to network...") 20 | sta_if.active(True) 21 | sta_if.connect(ssid, password) 22 | while not sta_if.isconnected(): 23 | pass 24 | print("network config:", sta_if.ifconfig()) 25 | 26 | # This function does a HTTP GET request 27 | # More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_tcp.html 28 | def http_get(url): 29 | import socket 30 | res = "" 31 | _, _, host, path = url.split("/", 3) 32 | addr = socket.getaddrinfo(host, 80)[0][-1] 33 | s = socket.socket() 34 | s.connect(addr) 35 | s.send(bytes("GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n" % (path, host), "utf8")) 36 | while True: 37 | data = s.recv(100) 38 | if data: 39 | res += str(data, "utf8") 40 | else: 41 | break 42 | s.close() 43 | return res 44 | 45 | # Main function 46 | if __name__ == "__main__": 47 | 48 | # First, connect 49 | do_connect() 50 | 51 | # Do a GET request to the micropython test page 52 | # If you were to do a GET request to a different page/resource, change the URL here 53 | response = http_get("http://micropython.org/ks/test.html") 54 | 55 | # Create and initialize our Inkplate object in 1-bit mode 56 | display = Inkplate(Inkplate.INKPLATE_1BIT) 57 | display.begin() 58 | 59 | # Set text size to double from the original size, so we can see the text better 60 | display.setTextSize(2) 61 | 62 | # Print response line by line 63 | cnt = 0 64 | for x in response.split("\n"): 65 | display.printText( 66 | 10, 20 + cnt, x.upper() 67 | ) # Default font has only upper case letters 68 | cnt += 20 69 | 70 | # Display image from buffer in full refresh 71 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/exampleSd.py: -------------------------------------------------------------------------------- 1 | # For this example, copy the files from the directory "Sd_card_example_files" 2 | # to an empty microSD card's root folder and then insert it into Inkplate 3 | 4 | # Include required libraries 5 | import os, time 6 | from soldered_inkplate6PLUS import Inkplate 7 | 8 | # Create Inkplate object in 2-bit (grayscale) mode 9 | display = Inkplate(Inkplate.INKPLATE_2BIT) 10 | 11 | # Main function 12 | if __name__ == "__main__": 13 | 14 | # Init Inkplate 15 | display.begin() 16 | 17 | # SD Card must be initialised with this function 18 | display.initSDCard() 19 | 20 | # This prints all the files on card 21 | print(os.listdir("/sd")) 22 | 23 | # Open the file text.txt in read only mode and print it's contents 24 | f = open("sd/text.txt", "r") 25 | print(f.read()) # This should print 5 lines of "Lorem Ipsum" 26 | f.close() # Close the file 27 | 28 | # Wait 5 seconds 29 | time.sleep(5) 30 | 31 | # Draw the image titled "1.bmp" 32 | # Warning, this takes quite a while 33 | # It's faster with smaller images or in 1-bit mode 34 | display.drawImageFile(0, 0, "sd/1.bmp") 35 | 36 | # You can turn off the power to the SD card to save power 37 | display.SDCardSleep() 38 | # To turn it back on, use: 39 | # display.SDCardWake() 40 | 41 | # Show the image from the buffer 42 | display.display() -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/frontlight.py: -------------------------------------------------------------------------------- 1 | # This example will show you how to adjust the frontlight 2 | 3 | # Include required libraries 4 | from soldered_inkplate6PLUS import Inkplate 5 | import time 6 | 7 | # Create Inkplate object in 1-bit (black and white) mode 8 | display = Inkplate(Inkplate.INKPLATE_1BIT) 9 | 10 | # Main function 11 | if __name__ == "__main__": 12 | 13 | # Initialize the display, needs to be called only once 14 | display.begin() 15 | 16 | # Clear the frame buffer 17 | display.clearDisplay() 18 | 19 | # This has to be called every time you want to update the screen 20 | # Drawing or printing text will have no effect on the display itself before you call this function 21 | display.display() 22 | 23 | # Enable the frontlight 24 | display.frontlight(True) 25 | 26 | # Frontlight strength can be set from values 0 to 64 27 | # For example: 28 | display.setFrontlight(10) 29 | 30 | # Wait 3 seconds 31 | time.sleep(3) 32 | 33 | # Slowly gradually increase the frontlight, infinitely 34 | while(True): 35 | # First, increase the brightness gradually 36 | for i in range(0, 60): 37 | display.setFrontlight(i) 38 | time.sleep(0.2) # Wait for 200ms -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/gpio_expander.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the GPIO expander's pins 2 | # Soldered Inkplate6PLUS has an internal and external GPIO expander 3 | # See below which pins are available 4 | 5 | # Include needed libraries 6 | import time 7 | from PCAL6416A import * 8 | from soldered_inkplate6 import Inkplate 9 | 10 | # Create Inkplate object in 1-bit mode, black and white colors only 11 | # For 2-bit grayscale, see basicGrayscale.py 12 | display = Inkplate(Inkplate.INKPLATE_1BIT) 13 | 14 | # Main function 15 | if __name__ == "__main__": 16 | 17 | # Initialize the display, needs to be called only once 18 | display.begin() 19 | 20 | # pin = display.gpioExpanderPin(gpioExpander,pin,mode) 21 | # Supported gpio expanders on Soldered Inkplate 6PLUS: 1, 2 (internal, external) 22 | # Supported modes: modeINPUT, modeINPUT_PULLUP, modeINPUT_PULLDOWN, modeOUTPUT 23 | # Supported pins on Soldered Inkplate 6PLUS are listed below 24 | 25 | # Declare all the available pins as output: 26 | 27 | expander2_P0_1 = display.gpioExpanderPin(1, 1, modeOUTPUT) 28 | expander2_P0_5 = display.gpioExpanderPin(2, 5, modeOUTPUT) 29 | expander2_P0_6 = display.gpioExpanderPin(2, 6, modeOUTPUT) 30 | expander2_P0_7 = display.gpioExpanderPin(2, 7, modeOUTPUT) 31 | 32 | expander2_P0_0 = display.gpioExpanderPin(2, 0, modeOUTPUT) 33 | expander2_P0_1 = display.gpioExpanderPin(2, 1, modeOUTPUT) 34 | expander2_P0_2 = display.gpioExpanderPin(2, 2, modeOUTPUT) 35 | expander2_P0_3 = display.gpioExpanderPin(2, 3, modeOUTPUT) 36 | expander2_P0_4 = display.gpioExpanderPin(2, 4, modeOUTPUT) 37 | expander2_P0_5 = display.gpioExpanderPin(2, 5, modeOUTPUT) 38 | expander2_P0_6 = display.gpioExpanderPin(2, 6, modeOUTPUT) 39 | expander2_P0_7 = display.gpioExpanderPin(2, 7, modeOUTPUT) 40 | 41 | expander2_P1_0 = display.gpioExpanderPin(2, 8, modeOUTPUT) 42 | expander2_P1_1 = display.gpioExpanderPin(2, 9, modeOUTPUT) 43 | expander2_P1_2 = display.gpioExpanderPin(2, 10, modeOUTPUT) 44 | expander2_P1_3 = display.gpioExpanderPin(2, 11, modeOUTPUT) 45 | expander2_P1_4 = display.gpioExpanderPin(2, 12, modeOUTPUT) 46 | expander2_P1_5 = display.gpioExpanderPin(2, 13, modeOUTPUT) 47 | expander2_P1_6 = display.gpioExpanderPin(2, 14, modeOUTPUT) 48 | expander2_P1_7 = display.gpioExpanderPin(2, 15, modeOUTPUT) 49 | 50 | # Take the previously declared pin 1_5 on expander 2 and blink it 51 | # To see the blinking, attatch a 300Ohm resistor and LED between that pin and GND 52 | while (1): 53 | expander2_P1_5.digitalWrite(1) 54 | time.sleep(0.5) 55 | expander2_P1_5.digitalWrite(0) 56 | time.sleep(0.5) 57 | # Infinite loop, this goes on forever -------------------------------------------------------------------------------- /Examples/Soldered_Inkplate6PLUS/touchscreen.py: -------------------------------------------------------------------------------- 1 | # This example shows you how to use the touchscreen on Inkplate6PLUS! 2 | 3 | # Include needed libraries 4 | from soldered_inkplate6PLUS import Inkplate 5 | 6 | # Create Inkplate object in 1-bit mode, black and white colors only 7 | display = Inkplate(Inkplate.INKPLATE_1BIT) 8 | 9 | # Main function 10 | if __name__ == "__main__": 11 | 12 | # Initialize the display, needs to be called only once 13 | display.begin() 14 | 15 | # Clear the frame buffer 16 | display.clearDisplay() 17 | 18 | # This has to be called every time you want to update the screen 19 | # Drawing or printing text will have no effect on the display itself before you call this function 20 | display.display() 21 | 22 | # Initialize the touchscreen 23 | display.tsInit(1) 24 | 25 | # Draw a rectangle right in the middle of the screen and show it 26 | display.drawRect(450, 350, 100, 100, display.BLACK) 27 | display.display() 28 | 29 | # Every time the user touches that rectangle, print a message 30 | # The messags get printed to the terminal where the script was ran from 31 | # Create the variable which counts how many times the rectangle was touched 32 | counter = 0 33 | while True: 34 | # If a touch on the square was detected 35 | if(display.touchInArea(450, 350, 100, 100)): 36 | # Increment the counter and print a message 37 | counter += 1 38 | print("Touch detected! Touch #: "+str(counter)) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Thorsten von Eicken 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PCAL6416A.py: -------------------------------------------------------------------------------- 1 | # MicroPython driver for the PCAL6416A GPIO expander 2 | # By Soldered Electronics 3 | # Based on the original contribution by https://github.com/tve 4 | from machine import Pin as mPin 5 | from micropython import const 6 | 7 | PCAL6416A_INPORT0 = const(0x00) 8 | PCAL6416A_INPORT1 = const(0x01) 9 | PCAL6416A_OUTPORT0 = const(0x02) 10 | PCAL6416A_OUTPORT1 = const(0x03) 11 | PCAL6416A_POLINVPORT0 = const(0x04) 12 | PCAL6416A_POLINVPORT1 = const(0x05) 13 | PCAL6416A_CFGPORT0 = const(0x06) 14 | PCAL6416A_CFGPORT1 = const(0x07) 15 | PCAL6416A_OUTDRVST_REG00 = const(0x40) 16 | PCAL6416A_OUTDRVST_REG01 = const(0x41) 17 | PCAL6416A_OUTDRVST_REG10 = const(0x42) 18 | PCAL6416A_OUTDRVST_REG11 = const(0x43) 19 | PCAL6416A_INLAT_REG0 = const(0x44) 20 | PCAL6416A_INLAT_REG1 = const(0x45) 21 | PCAL6416A_PUPDEN_REG0 = const(0x46) 22 | PCAL6416A_PUPDEN_REG1 = const(0x47) 23 | PCAL6416A_PUPDSEL_REG0 = const(0x48) 24 | PCAL6416A_PUPDSEL_REG1 = const(0x49) 25 | PCAL6416A_INTMSK_REG0 = const(0x4A) 26 | PCAL6416A_INTMSK_REG1 = const(0x4B) 27 | PCAL6416A_INTSTAT_REG0 = const(0x4C) 28 | PCAL6416A_INTSTAT_REG1 = const(0x4D) 29 | PCAL6416A_OUTPORT_CONF = const(0x4F) 30 | 31 | PCAL6416A_INPORT0_ARRAY = const(0) 32 | PCAL6416A_INPORT1_ARRAY = const(1) 33 | PCAL6416A_OUTPORT0_ARRAY = const(2) 34 | PCAL6416A_OUTPORT1_ARRAY = const(3) 35 | PCAL6416A_POLINVPORT0_ARRAY = const(4) 36 | PCAL6416A_POLINVPORT1_ARRAY = const(5) 37 | PCAL6416A_CFGPORT0_ARRAY = const(6) 38 | PCAL6416A_CFGPORT1_ARRAY = const(7) 39 | PCAL6416A_OUTDRVST_REG00_ARRAY = const(8) 40 | PCAL6416A_OUTDRVST_REG01_ARRAY = const(9) 41 | PCAL6416A_OUTDRVST_REG10_ARRAY = const(10) 42 | PCAL6416A_OUTDRVST_REG11_ARRAY = const(11) 43 | PCAL6416A_INLAT_REG0_ARRAY = const(12) 44 | PCAL6416A_INLAT_REG1_ARRAY = const(13) 45 | PCAL6416A_PUPDEN_REG0_ARRAY = const(14) 46 | PCAL6416A_PUPDEN_REG1_ARRAY = const(15) 47 | PCAL6416A_PUPDSEL_REG0_ARRAY = const(16) 48 | PCAL6416A_PUPDSEL_REG1_ARRAY = const(17) 49 | PCAL6416A_INTMSK_REG0_ARRAY = const(18) 50 | PCAL6416A_INTMSK_REG1_ARRAY = const(19) 51 | PCAL6416A_INTSTAT_REG0_ARRAY = const(20) 52 | PCAL6416A_INTSTAT_REG1_ARRAY = const(21) 53 | PCAL6416A_OUTPORT_CONF_ARRAY = const(22) 54 | 55 | IO_PIN_A0 = const(0) 56 | IO_PIN_A1 = const(1) 57 | IO_PIN_A2 = const(2) 58 | IO_PIN_A3 = const(3) 59 | IO_PIN_A4 = const(4) 60 | IO_PIN_A5 = const(5) 61 | IO_PIN_A6 = const(6) 62 | IO_PIN_A7 = const(7) 63 | IO_PIN_B0 = const(8) 64 | IO_PIN_B1 = const(9) 65 | IO_PIN_B2 = const(10) 66 | IO_PIN_B3 = const(11) 67 | IO_PIN_B4 = const(12) 68 | IO_PIN_B5 = const(13) 69 | IO_PIN_B6 = const(14) 70 | IO_PIN_B7 = const(15) 71 | 72 | modeINPUT = const(0) 73 | modeOUTPUT = const(1) 74 | modeINPUT_PULLUP = const(2) 75 | modeINPUT_PULLDOWN = const(3) 76 | 77 | # PCAL6416A is a minimal driver for an 16-bit I2C I/O expander 78 | class PCAL6416A: 79 | def __init__(self, i2c, addr=0x20): 80 | self.i2c = i2c 81 | self.addr = addr 82 | self.ioRegsInt = bytearray(23) 83 | 84 | self.ioRegsInt[0] = self.read(PCAL6416A_INPORT0) 85 | self.ioRegsInt[1] = self.read(PCAL6416A_INPORT1) 86 | self.ioRegsInt[2] = self.read(PCAL6416A_OUTPORT0) 87 | self.ioRegsInt[3] = self.read(PCAL6416A_OUTPORT1) 88 | self.ioRegsInt[4] = self.read(PCAL6416A_POLINVPORT0) 89 | self.ioRegsInt[5] = self.read(PCAL6416A_POLINVPORT1) 90 | self.ioRegsInt[6] = self.read(PCAL6416A_CFGPORT0) 91 | self.ioRegsInt[7] = self.read(PCAL6416A_CFGPORT1) 92 | self.ioRegsInt[8] = self.read(PCAL6416A_OUTDRVST_REG00) 93 | self.ioRegsInt[9] = self.read(PCAL6416A_OUTDRVST_REG01) 94 | self.ioRegsInt[10] = self.read(PCAL6416A_OUTDRVST_REG10) 95 | self.ioRegsInt[11] = self.read(PCAL6416A_OUTDRVST_REG11) 96 | self.ioRegsInt[12] = self.read(PCAL6416A_INLAT_REG0) 97 | self.ioRegsInt[13] = self.read(PCAL6416A_INLAT_REG1) 98 | self.ioRegsInt[14] = self.read(PCAL6416A_PUPDEN_REG0) 99 | self.ioRegsInt[15] = self.read(PCAL6416A_PUPDEN_REG1) 100 | self.ioRegsInt[16] = self.read(PCAL6416A_PUPDSEL_REG0) 101 | self.ioRegsInt[17] = self.read(PCAL6416A_PUPDSEL_REG1) 102 | self.ioRegsInt[18] = self.read(PCAL6416A_INTMSK_REG0) 103 | self.ioRegsInt[19] = self.read(PCAL6416A_INTMSK_REG1) 104 | self.ioRegsInt[20] = self.read(PCAL6416A_INTSTAT_REG0) 105 | self.ioRegsInt[21] = self.read(PCAL6416A_INTSTAT_REG1) 106 | self.ioRegsInt[22] = self.read(PCAL6416A_OUTPORT_CONF) 107 | 108 | # read an 8-bit register, internal method 109 | def read(self, reg): 110 | return self.i2c.readfrom_mem(self.addr, reg, 1)[0] 111 | 112 | # write an 8-bit register, internal method 113 | def write(self, reg, v): 114 | self.i2c.writeto_mem(self.addr, reg, bytes((v,))) 115 | 116 | # write two 8-bit registers, internal method 117 | def write2(self, reg, v1, v2): 118 | self.i2c.writeto_mem(self.addr, reg, bytes((v1, v2))) 119 | 120 | # writebuf writes multiple bytes to the same register 121 | def writebuf(self, reg, v): 122 | self.i2c.writeto_mem(self.addr, reg, v) 123 | 124 | def pinMode(self, pin, mode): 125 | 126 | if (pin > 15): 127 | return 128 | 129 | port = pin // 8 130 | pin = pin % 8 131 | 132 | if (mode == modeINPUT): 133 | self.ioRegsInt[PCAL6416A_CFGPORT0_ARRAY + port] |= (1 << pin) 134 | self.write(PCAL6416A_CFGPORT0 + port, 135 | self.ioRegsInt[PCAL6416A_CFGPORT0_ARRAY + port]) 136 | elif (mode == modeOUTPUT): 137 | self.ioRegsInt[PCAL6416A_CFGPORT0_ARRAY + port] &= ~ (1 << pin) 138 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port] &= ~(1 << pin) 139 | self.write(PCAL6416A_OUTPORT0 + port, 140 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port]) 141 | self.write(PCAL6416A_CFGPORT0 + port, 142 | self.ioRegsInt[PCAL6416A_CFGPORT0_ARRAY + port]) 143 | elif (mode == modeINPUT_PULLUP): 144 | self.ioRegsInt[PCAL6416A_CFGPORT0_ARRAY + port] |= (1 << pin) 145 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port] |= (1 << pin) 146 | self.ioRegsInt[PCAL6416A_PUPDSEL_REG0_ARRAY + port] |= (1 << pin) 147 | self.write(PCAL6416A_OUTPORT0 + port, 148 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port]) 149 | self.write(PCAL6416A_CFGPORT0 + port, 150 | self.ioRegsInt[PCAL6416A_CFGPORT0_ARRAY + port]) 151 | self.write(PCAL6416A_PUPDSEL_REG0 + port, 152 | self.ioRegsInt[PCAL6416A_PUPDSEL_REG0_ARRAY + port]) 153 | elif (mode == modeINPUT_PULLDOWN): 154 | self.ioRegsInt[PCAL6416A_CFGPORT0_ARRAY + port] |= (1 << pin) 155 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port] |= (1 << pin) 156 | self.ioRegsInt[PCAL6416A_PUPDSEL_REG0_ARRAY + port] &= ~(1 << pin) 157 | self.write(PCAL6416A_OUTPORT0 + port, 158 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port]) 159 | self.write(PCAL6416A_CFGPORT0 + port, 160 | self.ioRegsInt[PCAL6416A_CFGPORT0_ARRAY + port]) 161 | self.write(PCAL6416A_PUPDSEL_REG0 + port, 162 | self.ioRegsInt[PCAL6416A_PUPDSEL_REG0_ARRAY + port]) 163 | 164 | def digitalWrite(self, pin, state): 165 | if (pin > 15): 166 | return 167 | 168 | state &= 1 169 | port = pin // 8 170 | pin %= 8 171 | 172 | if (state): 173 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port] |= (1 << pin) 174 | else: 175 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port] &= ~(1 << pin) 176 | 177 | self.write(PCAL6416A_OUTPORT0 + port, 178 | self.ioRegsInt[PCAL6416A_OUTPORT0_ARRAY + port]) 179 | 180 | def digitalRead(self, pin): 181 | if (pin > 15): 182 | return 183 | 184 | port = pin // 8 185 | pin %= 8 186 | 187 | self.ioRegsInt[PCAL6416A_INPORT0_ARRAY + 188 | port] = self.read(PCAL6416A_INPORT0_ARRAY + port) 189 | return (self.ioRegsInt[PCAL6416A_INPORT0 + port] >> pin) & 1 190 | 191 | class gpioPin: 192 | def __init__(self, PCAL6416A, pin, mode): 193 | self.PCAL6416A = PCAL6416A 194 | self.pin = pin 195 | self.PCAL6416A.pinMode(pin,mode) 196 | 197 | def digitalWrite(self, value): 198 | self.PCAL6416A.digitalWrite(self.pin,value) 199 | 200 | def digitalRead(self): 201 | return self.PCAL6416A.digitalRead(self.pin) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Soldered Inkplate Micropython library 2 | 3 | ![](https://raw.githubusercontent.com/SolderedElectronics/Inkplate-Arduino-library/master/extras/InkplateImage.jpg) 4 | 5 | The Micropython modules for the Inkplate product family can befound in this repository. Inkplate is a series of powerful, Wi-Fi and Bluetooth enabled, ESP32-based ePaper display products. Its main feature is simplicity. Just plug in a USB cable, load the MicroPython firmware and the required libraries and run your script on Inkplate itself. The Inkplate product family currently includes Inkplate 10, Inkplate 6 and Inkplate 6PLUS, Inkplate 6COLOR and Inkplate 2. 6 | Inkplate 6 was crowdfunded on [Crowd Supply](https://www.crowdsupply.com/e-radionica/inkplate-6), as well as [Inkplate 10](https://www.crowdsupply.com/e-radionica/inkplate-10), [Inkplate 6PLUS](https://www.crowdsupply.com/e-radionica/inkplate-6plus) and [Inkplate 6COLOR](https://www.crowdsupply.com/soldered/inkplate-6color). Inkplate 2 was funded on [Kickstarter](https://www.kickstarter.com/projects/solderedelectronics/inkplate-2-a-easy-to-use-arduino-compatible-e-paper). 7 | 8 | All available to purchase from [Soldered.com](https://soldered.com/categories/inkplate/). 9 | 10 | Original effort to enable MicroPython support for Inkplate was done by [tve](https://github.com/tve/micropython-inkplate6). Thank you! 11 | 12 | ### Setting up Inkplate with MicroPython 13 | 14 | In order to get started with running your code on Inkplate, follow these steps: 15 | 1. Install esptool - the command line tool used to upload firmware to the ESP32. Get it from [here](https://github.com/espressif/esptool) (https://github.com/espressif/esptool). Also, install PySerial as it's a requirement. You can download PySerial [here](https://pypi.org/project/pyserial/) (https://pypi.org/project/pyserial). Place them in a both in a working directory. 16 | 17 | 2. Download this repository by clicking Code -> Download as .zip, or clone it. Extract to your desired working directory for your MicroPython files, make it a different one than the esptool directory. 18 | 19 | 3. Copy the esp32spiram-20220117-v1.18.bin file to the esptool directory from the MicroPython directory. Then,open your terminal/command prompt in the esptool directory. 20 | 21 | 4. Now we need to flash the MicroPython firmware to Inkplate. It is reccomended to flash the one supplied in this repository that you have copied in the previous step, version 1.18. To do this, connect Inkplate via USB-C and first erase the flash memory by running this command: 22 | ``` 23 | // Linux/Mac 24 | python3 esptool.py --port /dev/cu.usbserial-1420 erase_flash 25 | 26 | // Windows 27 | python esptool.py --port COM5 erase_flash 28 | ``` 29 | 30 | If you're having problems on Windows, use: 31 | ``` 32 | esptool --port COM5 erase_flash 33 | ``` 34 | 35 | **NOTE:** You should change the serial port listed here to the one which corresponds to your connected Inkplate device. 36 | 37 | Now it's possible to flash MicroPython firmware. Do so by running this command: 38 | ``` 39 | // Linux/Mac 40 | python3 esptool.py --chip esp32 --port /dev/cu.usbserial-1420 write_flash -z 0x1000 esp32spiram-20220117-v1.18.bin 41 | // If you're having problems on Mac, use a slower baud rate with the flag "-b 115200" 42 | 43 | // Windows 44 | python esptool.py --chip esp32 --port COM5 write_flash -z 0x1000 esp32spiram-20220117-v1.18.bin 45 | ``` 46 | 47 | **You only have to do steps 1-4 once when writing MicroPython firmware on your Inkplate!** If you have already done this, proceed from step 5 onwards. 48 | 49 | 5. Open a terminal in your MicroPython folder. Now, it's required to copy all the library files and drivers for your Inkplate board, so your MicroPython script can run. Do so with the following command: 50 | 51 | ``` 52 | // Linux/Mac 53 | python3 pyboard.py --device /dev/ttyUSB0 -f cp mcp23017.py inkplate6.py image.py shapes.py gfx.py gfx_standard_font_01.py soldered_logo.py : 54 | 55 | // Windows 56 | // This one might need to be started twice 57 | python pyboard.py --device COM5 -f cp inkplate6.py gfx.py gfx_standard_font_01.py mcp23017.py PCAL6416A.py image.py shapes.py soldered_logo.py : 58 | ``` 59 | 60 | **NOTE:** here you need to again change the serial port to the one you're using and the main driver of the board to the one made specifically for your Inkplate board. Here it's inkplate6.py for Inkplate 6. If you have a newer version of Inkplate 6 (Soldered Inkplate 6) then copy soldered_inkplate6.py instead. inkplate2.py for Inkplate 2, and so on. Older Inkplate boards use 'mcp23017.py' for the IO expander and the new ones use PCAL6416A.py, so you only need to copy one of them. Check the driver file for your Inkplate board to see which one it requires. 61 | 62 | In this command you also need to include all the files your Python script uses (external images, files with extenral functions you're including and so on) so it can run on your board! 63 | 64 | 7. Finally, it's time to run the MicroPython script which will actually run on the device. To demonstrate, we will run the basicBW.py example for Inkplate 6. To run the script, execute the following command: 65 | 66 | ``` 67 | // Linux/Mac 68 | python3 pyboard.py --device /dev/ttyUSB0 "Examples/Inkplate6/basicBW.py" 69 | 70 | // Windows 71 | python pyboard.py --device COM5 "Examples/Inkplate6/basicBW.py" 72 | ``` 73 | 74 | You can try other examples which will show you all the features of the device. 75 | 76 | 77 | ### Code examples 78 | 79 | There are several examples which will indicate all the functions you can use in your own script: 80 | * The basic examples show you drawing shapes, lines and text on the screen in different colors, also a bitmap image in a single color 81 | * The network examples show you how to use the network features like doing a GET request and downloading a file 82 | * The batteryAndTemperatureRead examples show you how to read the internal battery status and the temperature from the internal sensor 83 | * The exampleSD example shows you how to read image files and text from the SD card 84 | * The gpio_expander example shows how to use the GPIO expander on new Inkplate models 85 | * The touchpad examples show you how to use the touchpad on older Inkplates 86 | 87 | More information is provided in the examples themselves in the shape of comments. 88 | 89 | ### Documentation 90 | 91 | Find Inkplate documentation [here](https://inkplate.readthedocs.io/). 92 | 93 | ### Battery power 94 | 95 | Inkplate boards have two options for powering it. The first one is obvious - USB port at side of the board. Just plug any microUSB/USB-C (depending on your board version) cable and you are good to go. The second option is using a battery. Supported batteries are standard Li-Ion/Li-Poly batteries with a 3.7V nominal voltage. Connector for the battery is standard 2.00mm pitch JST connector (except on Inkplate 2, it uses SMD solder pads for battery terminals). The onboard charger will charge the battery with 500mA when USB is plugged at the same time. You can use battery of any size or capacity if you don't have a enclosure. If you are using our enclosure, battery size shouldn't exceed 90mm x 40mm (3.5 x 1.57 inch) and 5mm (0.19 inch) in height (excluding Inkplate 2, it uses [this battery](https://soldered.com/product/li-ion-baterija-600mah-3-7v/). [This battery](https://soldered.com/product/li-ion-battery-1200mah-3-7v/) is a good fit for all Inkplate models. Also, Inkplate's hardware is specially optimized for low power consumption in deep sleep mode, making it extremely suitable for battery applications. 96 | 97 | #### ⚠️ WARNING 98 | Please check the polarity on the battery JST connector! Some batteries that can be purchased from the web have reversed polarity that can damage Inkplate board! You are safe if you are using the pouch battery from [soldered.com](https://soldered.com/categories/power-sources-batteries/batteries/lithium-batteries/) or Inkplate with the built-in battery . 99 | 100 | #### ℹ NOTE 101 | CR2032 battery is only for RTC backup. Inkplate cannot be powered with it. 102 | 103 | ### License 104 | 105 | This repo is licensed with the MIT License. For more info, see LICENSE. 106 | 107 | ### Open-source 108 | 109 | All of Inkplate-related development is open-sourced: 110 | 111 | - [Arduino library](https://github.com/SolderedElectronics/Inkplate-Arduino-library) 112 | - Hardware design: 113 | - [Soldered Inkplate 2](https://github.com/SolderedElectronics/Soldered-Inkplate-2-hardware-design) 114 | - [Soldered Inkplate 6](https://github.com/SolderedElectronics/Soldered-Inkplate-6-hardware-design) 115 | - [Soldered Inkplate 6PLUS](https://github.com/SolderedElectronics/Soldered-Inkplate-6PLUS-hardware-design) 116 | - [Soldered Inkplate 10](https://github.com/SolderedElectronics/Soldered-Inkplate-10-hardware-design) 117 | - [Soldered Inkplate 6COLOR](https://github.com/SolderedElectronics/Soldered-Inkplate-6COLOR-hardware-design) 118 | - [e-radionica.com Inkplate 6](https://github.com/SolderedElectronics/Inkplate-6-hardware) 119 | - [e-radionica.com Inkplate 10](https://github.com/SolderedElectronics/Inkplate-10-hardware) 120 | - [e-radionica.com Inkplate 6PLUS](https://github.com/SolderedElectronics/Inkplate-6PLUS-Hardware) 121 | - [OSHWA cerfiticates](https://certification.oshwa.org/list.html?q=inkplate) 122 | 123 | ### Where to buy 124 | 125 | Inkplate boards are available for purchase via: 126 | 127 | - [soldered.com](https://soldered.com/categories/inkplate/) 128 | - [Crowd Supply](https://www.crowdsupply.com/soldered) 129 | - [Mouser](https://hr.mouser.com/Search/Refine?Keyword=inkplate) 130 | 131 | For all questions and issues please reach us via [e-mail](mailto:hello@soldered.com) or our [contact form](https://soldered.com/contact/). 132 | -------------------------------------------------------------------------------- /esp32spiram-20220117-v1.18.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SolderedElectronics/Inkplate-micropython/8d8ad85a9799d4843be0d38a52ed04309fbbf77a/esp32spiram-20220117-v1.18.bin -------------------------------------------------------------------------------- /gfx_standard_font_01.py: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 2018 Jonah Yolles-Murphy for Makers Anywhere! 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | """ 23 | `gfx_standard_font_01` 24 | ==================================================== 25 | 26 | CircuitPython pixel graphics drawing library. 27 | 28 | * Author(s): Jonah Yolles-Murphy 29 | 30 | Implementation Notes 31 | -------------------- 32 | 33 | **Hardware:** 34 | 35 | **Software and Dependencies:** 36 | 37 | * Adafruit CircuitPython firmware for the supported boards: 38 | https://github.com/adafruit/circuitpython/releases 39 | 40 | * letter format: 41 | { 'character_here' : bytearray(WIDTH,HEIGHT,right-most-data,more-bytes-here,left-most-data')} 42 | the right most bit is the top most bit of each vertical stripe of a char 43 | * Key format: 44 | keys of one length only represent one character. longer then one is either 45 | extended characters or special characters like the degree sign. 46 | all extended or special charaters have all capitalized keys. 47 | "?CHAR?" is used when an input character is not in the font dictionary 48 | 49 | """ 50 | # pylint: disable=invalid-name 51 | text_dict = { 52 | "A": bytearray(b"\x05\x07?DDD?"), 53 | "B": bytearray(b"\x05\x07\x7fAII6"), 54 | "C": bytearray(b'\x05\x07>AAA"'), 55 | "D": bytearray(b'\x05\x07\x7fAA"\x1c'), 56 | "E": bytearray(b"\x05\x07\x7fIIIA"), 57 | "F": bytearray(b"\x05\x07\x7fHH@@"), 58 | "G": bytearray(b"\x05\x07>AII."), 59 | "H": bytearray(b"\x05\x07\x7f\x08\x08\x08\x7f"), 60 | "I": bytearray(b"\x05\x07AA\x7fAA"), 61 | "J": bytearray(b"\x05\x07FA~@@"), 62 | "K": bytearray(b"\x05\x07\x7f\x08\x08t\x03"), 63 | "L": bytearray(b"\x05\x07\x7f\x01\x01\x01\x01"), 64 | "M": bytearray(b"\x05\x07\x7f \x10 \x7f"), 65 | "N": bytearray(b"\x05\x07\x7f \x1c\x02\x7f"), 66 | "O": bytearray(b"\x05\x07>AAA>"), 67 | "P": bytearray(b"\x05\x07\x7fHHH0"), 68 | "Q": bytearray(b"\x05\x07>AEB="), 69 | "R": bytearray(b"\x05\x07\x7fHLJ1"), 70 | "S": bytearray(b"\x05\x072III&"), 71 | "T": bytearray(b"\x05\x07@@\x7f@@"), 72 | "U": bytearray(b"\x05\x07~\x01\x01\x01~"), 73 | "V": bytearray(b"\x05\x07p\x0e\x01\x0ep"), 74 | "W": bytearray(b"\x05\x07|\x03\x04\x03|"), 75 | "X": bytearray(b"\x05\x07c\x14\x08\x14c"), 76 | "Y": bytearray(b"\x05\x07`\x10\x0f\x10`"), 77 | "Z": bytearray(b"\x05\x07CEIQa"), 78 | 79 | #until we get proper support for lowercase letters 80 | "a": bytearray(b"\x05\x07?DDD?"), 81 | "b": bytearray(b"\x05\x07\x7fAII6"), 82 | "c": bytearray(b'\x05\x07>AAA"'), 83 | "d": bytearray(b'\x05\x07\x7fAA"\x1c'), 84 | "e": bytearray(b"\x05\x07\x7fIIIA"), 85 | "f": bytearray(b"\x05\x07\x7fHH@@"), 86 | "g": bytearray(b"\x05\x07>AII."), 87 | "h": bytearray(b"\x05\x07\x7f\x08\x08\x08\x7f"), 88 | "i": bytearray(b"\x05\x07AA\x7fAA"), 89 | "j": bytearray(b"\x05\x07FA~@@"), 90 | "k": bytearray(b"\x05\x07\x7f\x08\x08t\x03"), 91 | "l": bytearray(b"\x05\x07\x7f\x01\x01\x01\x01"), 92 | "m": bytearray(b"\x05\x07\x7f \x10 \x7f"), 93 | "n": bytearray(b"\x05\x07\x7f \x1c\x02\x7f"), 94 | "o": bytearray(b"\x05\x07>AAA>"), 95 | "p": bytearray(b"\x05\x07\x7fHHH0"), 96 | "q": bytearray(b"\x05\x07>AEB="), 97 | "r": bytearray(b"\x05\x07\x7fHLJ1"), 98 | "s": bytearray(b"\x05\x072III&"), 99 | "t": bytearray(b"\x05\x07@@\x7f@@"), 100 | "u": bytearray(b"\x05\x07~\x01\x01\x01~"), 101 | "v": bytearray(b"\x05\x07p\x0e\x01\x0ep"), 102 | "w": bytearray(b"\x05\x07|\x03\x04\x03|"), 103 | "x": bytearray(b"\x05\x07c\x14\x08\x14c"), 104 | "y": bytearray(b"\x05\x07`\x10\x0f\x10`"), 105 | "z": bytearray(b"\x05\x07CEIQa"), 106 | 107 | "0": bytearray(b"\x05\x07>EIQ>"), 108 | "1": bytearray(b"\x05\x07\x11!\x7f\x01\x01"), 109 | "2": bytearray(b"\x05\x07!CEI1"), 110 | "3": bytearray(b"\x05\x07FAQiF"), 111 | "4": bytearray(b"\x05\x07x\x08\x08\x08\x7f"), 112 | "5": bytearray(b"\x05\x07rQQQN"), 113 | "6": bytearray(b"\x05\x07\x1e)II\x06"), 114 | "7": bytearray(b"\x05\x07@GHP`"), 115 | "8": bytearray(b"\x05\x076III6"), 116 | "9": bytearray(b"\x05\x070IIJ<"), 117 | ")": bytearray(b"\x05\x07\x00A>\x00\x00"), 118 | "(": bytearray(b"\x05\x07\x00\x00>A\x00"), 119 | "[": bytearray(b"\x05\x07\x00\x00\x7fA\x00"), 120 | "]": bytearray(b"\x05\x07\x00A\x7f\x00\x00"), 121 | ".": bytearray(b"\x05\x07\x00\x03\x03\x00\x00"), 122 | "'": bytearray(b"\x05\x07\x00\x000\x00\x00"), 123 | ":": bytearray(b"\x05\x07\x00\x0066\x00"), 124 | "?CHAR?": bytearray(b"\x05\x07\x7f_RG\x7f"), 125 | "!": bytearray(b"\x05\x07\x00{{\x00\x00"), 126 | "?": bytearray(b"\x05\x07 @EH0"), 127 | ",": bytearray(b"\x05\x07\x00\x05\x06\x00\x00"), 128 | ";": bytearray(b"\x05\x07\x0056\x00\x00"), 129 | "/": bytearray(b"\x05\x07\x01\x06\x080@"), 130 | ">": bytearray(b"\x05\x07Ac6\x1c\x08"), 131 | "<": bytearray(b"\x05\x07\x08\x1c6cA"), 132 | "%": bytearray(b"\x05\x07af\x083C"), 133 | "@": bytearray(b"\x05\x07&IOA>"), 134 | "#": bytearray(b"\x05\x07\x14\x7f\x14\x7f\x14"), 135 | "$": bytearray(b"\x05\x072I\x7fI&"), 136 | "&": bytearray(b'\x05\x076IU"\x05'), 137 | "*": bytearray(b"\x05\x07(\x10|\x10("), 138 | "-": bytearray(b"\x05\x07\x00\x08\x08\x08\x00"), 139 | "_": bytearray(b"\x05\x07\x01\x01\x01\x01\x01"), 140 | "+": bytearray(b"\x05\x07\x08\x08>\x08\x08"), 141 | "=": bytearray(b"\x05\x07\x00\x14\x14\x14\x00"), 142 | '"': bytearray(b"\x05\x07\x00p\x00p\x00"), 143 | "`": bytearray(b"\x05\x07\x00\x00 \x10\x00"), 144 | "~": bytearray(b"\x05\x07\x08\x10\x08\x04\x08"), 145 | " ": bytearray(b"\x05\x07\x00\x00\x00\x00\x00"), 146 | "^": bytearray(b"\x05\x07\x10 @ \x10"), 147 | "NONE": bytearray(b"\x00\x07"), 148 | "BLANK": bytearray(b"\x05\x07\x00\x00\x00\x00\x00"), 149 | "BATA0": bytearray(b"\x0b\x07\x7fAAAAAAAA\x7f\x1c"), 150 | "BATA1": bytearray(b"\x0b\x07\x7fA]AAAAAA\x7f\x1c"), 151 | "BATA2": bytearray(b"\x0b\x07\x7fA]]AAAAA\x7f\x1c"), 152 | "BATA3": bytearray(b"\x0b\x07\x7fA]]]AAAA\x7f\x1c"), 153 | "BATA4": bytearray(b"\x0b\x07\x7fA]]]]AAA\x7f\x1c"), 154 | "BATA5": bytearray(b"\x0b\x07\x7fA]]]]]AA\x7f\x1c"), 155 | "BATA6": bytearray(b"\x0b\x07\x7fA]]]]]]A\x7f\x1c"), 156 | "BATACHRG": bytearray(b"\x07\x08\x7fAIYyOMIA\x7f\x1c"), 157 | "BATB0": bytearray(b"\x0b\x07\x7fAAAAAAAA\x7f\x1c"), 158 | "FULL": bytearray(b"\x05\x07\x7f\x7f\x7f\x7f\x7f"), 159 | "\n": bytearray(b"\x05\x07\x00\x00\x00\x00\x00"), 160 | "DEGREESIGN": bytearray(b"\x05\x07\x18$$\x18\x00"), 161 | } 162 | -------------------------------------------------------------------------------- /i2c_scanner.py: -------------------------------------------------------------------------------- 1 | # Scanner i2c en MicroPython | MicroPython i2c scanner 2 | # Renvoi l'adresse en decimal et hexa de chaque device connecte sur le bus i2c 3 | # Return decimal and hexa adress of each i2c device 4 | # https://projetsdiy.fr - https://diyprojects.io (dec. 2017) 5 | 6 | import machine 7 | i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21)) 8 | 9 | print('Scan i2c bus...') 10 | devices = i2c.scan() 11 | 12 | if len(devices) == 0: 13 | print("No i2c device !") 14 | else: 15 | print('i2c devices found:',len(devices)) 16 | 17 | for device in devices: 18 | print("Decimal address: ",device," | Hexa address: ",hex(device)) -------------------------------------------------------------------------------- /inkplate2.py: -------------------------------------------------------------------------------- 1 | # MicroPython driver for Inkplate 2 2 | # By Soldered Electronics 3 | # Based on the original contribution by https://github.com/tve 4 | import time 5 | import os 6 | from machine import ADC, I2C, SPI, Pin 7 | from micropython import const 8 | from shapes import Shapes 9 | from machine import Pin as mPin 10 | from gfx import GFX 11 | from gfx_standard_font_01 import text_dict as std_font 12 | 13 | # Connections between ESP32 and color Epaper 14 | EPAPER_RST_PIN = const(19) 15 | EPAPER_DC_PIN = const(33) 16 | EPAPER_CS_PIN = const(27) 17 | EPAPER_BUSY_PIN = const(32) 18 | EPAPER_CLK = const(18) 19 | EPAPER_DIN = const(23) 20 | 21 | pixelMaskLUT = [0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80] 22 | pixelMaskGLUT = [0xF, 0xF0] 23 | 24 | # ePaper resolution 25 | # For Inkplate2 height and width are swapped in relation to the default rotation 26 | E_INK_HEIGHT = 212 27 | E_INK_WIDTH = 104 28 | 29 | E_INK_NUM_PIXELS = E_INK_HEIGHT * E_INK_WIDTH 30 | E_INK_BUFFER_SIZE = E_INK_NUM_PIXELS // 8 31 | 32 | busy_timeout_ms = 30000 33 | 34 | 35 | class Inkplate: 36 | 37 | # Colors 38 | WHITE = 0b00000000 39 | BLACK = 0b00000001 40 | RED = 0b00000010 41 | 42 | _width = E_INK_WIDTH 43 | _height = E_INK_HEIGHT 44 | 45 | rotation = 0 46 | textSize = 1 47 | 48 | _panelState = False 49 | 50 | _framebuf_BW = bytearray([0xFF] * E_INK_BUFFER_SIZE) 51 | _framebuf_RED = bytearray([0xFF] * E_INK_BUFFER_SIZE) 52 | 53 | @classmethod 54 | def begin(self): 55 | self.wire = I2C(0, scl=Pin(22), sda=Pin(21)) 56 | self.spi = SPI(2) 57 | self._framebuf_BW = bytearray(([0xFF] * E_INK_BUFFER_SIZE)) 58 | self._framebuf_RED = bytearray(([0xFF] * E_INK_BUFFER_SIZE)) 59 | 60 | self.GFX = GFX( 61 | E_INK_HEIGHT, 62 | E_INK_WIDTH, 63 | self.writePixel, 64 | self.writeFastHLine, 65 | self.writeFastVLine, 66 | self.writeFillRect, 67 | None, 68 | None, 69 | ) 70 | 71 | # Wake the panel and init it 72 | if not (self.setPanelDeepSleepState(False)): 73 | return False 74 | 75 | # Put it back to sleep 76 | self.setPanelDeepSleepState(True) 77 | 78 | # 3 is the default rotation for Inkplate 2 79 | self.setRotation(3) 80 | 81 | return True 82 | 83 | @classmethod 84 | def getPanelDeepSleepState(self): 85 | return self._panelState 86 | 87 | @classmethod 88 | def setPanelDeepSleepState(self, state): 89 | 90 | # False wakes the panel up 91 | # True puts it to sleep 92 | if not state: 93 | self.spi.init(baudrate=20000000, firstbit=SPI.MSB, 94 | polarity=0, phase=0) 95 | self.EPAPER_BUSY_PIN = Pin(EPAPER_BUSY_PIN, Pin.IN) 96 | self.EPAPER_RST_PIN = Pin(EPAPER_RST_PIN, Pin.OUT) 97 | self.EPAPER_DC_PIN = Pin(EPAPER_DC_PIN, Pin.OUT) 98 | self.EPAPER_CS_PIN = Pin(EPAPER_CS_PIN, Pin.OUT) 99 | time.sleep_ms(10) 100 | self.resetPanel() 101 | 102 | # Reinit the panel 103 | self.sendCommand(b"\x04") 104 | _timeout = time.ticks_ms() 105 | while not self.EPAPER_BUSY_PIN.value() and (time.ticks_ms() - _timeout) < busy_timeout_ms: 106 | pass 107 | 108 | self.sendCommand(b"\x00") 109 | self.sendData(b"\x0f") 110 | self.sendData(b"\x89") 111 | self.sendCommand(b"\x61") 112 | self.sendData(b"\x68") 113 | self.sendData(b"\x00") 114 | self.sendData(b"\xD4") 115 | self.sendCommand(b"\x50") 116 | self.sendData(b"\x77") 117 | 118 | self._panelState = True 119 | 120 | return True 121 | 122 | else: 123 | 124 | # Put the panel to sleep 125 | self.sendCommand(b"\x50") 126 | self.sendData(b"\xf7") 127 | self.sendCommand(b"\x02") 128 | # Wait for ePaper 129 | _timeout = time.ticks_ms() 130 | while not self.EPAPER_BUSY_PIN.value() and (time.ticks_ms() - _timeout) < busy_timeout_ms: 131 | pass 132 | self.sendCommand(b"\07") 133 | self.sendData(b"\xA5") 134 | 135 | time.sleep_ms(1) 136 | # Turn off SPI 137 | self.spi.deinit() 138 | self.EPAPER_BUSY_PIN = Pin(EPAPER_BUSY_PIN, Pin.IN) 139 | self.EPAPER_RST_PIN = Pin(EPAPER_RST_PIN, Pin.IN) 140 | self.EPAPER_DC_PIN = Pin(EPAPER_DC_PIN, Pin.IN) 141 | self.EPAPER_CS_PIN = Pin(EPAPER_CS_PIN, Pin.IN) 142 | 143 | self._panelState = False 144 | 145 | return False 146 | 147 | @classmethod 148 | def resetPanel(self): 149 | self.EPAPER_RST_PIN.value(0) 150 | time.sleep_ms(10) 151 | self.EPAPER_RST_PIN.value(1) 152 | time.sleep_ms(10) 153 | 154 | @classmethod 155 | def sendCommand(self, command): 156 | self.EPAPER_DC_PIN.value(0) 157 | self.EPAPER_CS_PIN.value(0) 158 | self.spi.write(command) 159 | 160 | self.EPAPER_CS_PIN.value(1) 161 | 162 | @classmethod 163 | def sendData(self, data): 164 | self.EPAPER_CS_PIN.value(0) 165 | self.EPAPER_DC_PIN.value(1) 166 | self.spi.write(data) 167 | 168 | self.EPAPER_CS_PIN.value(1) 169 | time.sleep_ms(1) 170 | 171 | @classmethod 172 | def clearDisplay(self): 173 | self._framebuf_BW = bytearray(([0xFF] * E_INK_BUFFER_SIZE)) 174 | self._framebuf_RED = bytearray(([0xFF] * E_INK_BUFFER_SIZE)) 175 | 176 | @classmethod 177 | def display(self): 178 | 179 | # Wake the display 180 | self.setPanelDeepSleepState(False) 181 | 182 | # Write b/w pixels 183 | self.sendCommand(b"\x10") 184 | self.sendData(self._framebuf_BW) 185 | 186 | # Write red pixels 187 | self.sendCommand(b"\x13") 188 | self.sendData(self._framebuf_RED) 189 | 190 | # Stop transfer 191 | self.sendCommand(b"\x11") 192 | self.sendData(b"\x00") 193 | 194 | # Refresh 195 | self.sendCommand(b"\x12") 196 | time.sleep_ms(5) 197 | 198 | _timeout = time.ticks_ms() 199 | while not self.EPAPER_BUSY_PIN.value() and (time.ticks_ms() - _timeout) < busy_timeout_ms: 200 | pass 201 | 202 | # Put the display back to sleep 203 | self.setPanelDeepSleepState(True) 204 | 205 | @classmethod 206 | def width(self): 207 | return self._width 208 | 209 | @classmethod 210 | def height(self): 211 | return self._height 212 | 213 | # Arduino compatibility functions 214 | @classmethod 215 | def setRotation(self, x): 216 | self.rotation = x % 4 217 | if self.rotation == 0 or self.rotation == 2: 218 | self.GFX.width = E_INK_WIDTH 219 | self.GFX.height = E_INK_HEIGHT 220 | self._width = E_INK_WIDTH 221 | self._height = E_INK_HEIGHT 222 | elif self.rotation == 1 or self.rotation == 3: 223 | self.GFX.width = E_INK_HEIGHT 224 | self.GFX.height = E_INK_WIDTH 225 | self._width = E_INK_HEIGHT 226 | self._height = E_INK_WIDTH 227 | 228 | @classmethod 229 | def getRotation(self): 230 | return self.rotation 231 | 232 | @classmethod 233 | def drawPixel(self, x, y, c): 234 | self.startWrite() 235 | self.writePixel(x, y, c) 236 | self.endWrite() 237 | 238 | @classmethod 239 | def startWrite(self): 240 | pass 241 | 242 | @classmethod 243 | def writePixel(self, x, y, c): 244 | if x > self.width() - 1 or y > self.height() - 1 or x < 0 or y < 0: 245 | return 246 | if (c > 2): 247 | return 248 | 249 | if self.rotation == 3: 250 | x, y = y, x 251 | y = self.width() - y - 1 252 | elif self.rotation == 0: 253 | x = self.width() - x - 1 254 | y = self.height() - y - 1 255 | elif self.rotation == 1: 256 | x, y = y, x 257 | x = self.height() - x - 1 258 | elif self.rotation == 2: 259 | pass 260 | 261 | _x = x // 8 262 | _x_sub = x % 8 263 | _position = E_INK_WIDTH // 8 * y + _x 264 | 265 | # Clear both black and red frame buffer 266 | self._framebuf_BW[_position] |= (pixelMaskLUT[7 - _x_sub]) 267 | self._framebuf_RED[_position] |= (pixelMaskLUT[7 - _x_sub]) 268 | 269 | # Write the pixel to the according buffer 270 | if (c < 2): 271 | self._framebuf_BW[_position] &= ~(c << (7 - _x_sub)) 272 | else: 273 | self._framebuf_RED[_position] &= ~(pixelMaskLUT[7 - _x_sub]) 274 | 275 | @classmethod 276 | def writeFillRect(self, x, y, w, h, c): 277 | for j in range(w): 278 | for i in range(h): 279 | self.writePixel(x + j, y + i, c) 280 | 281 | @classmethod 282 | def writeFastVLine(self, x, y, h, c): 283 | for i in range(h): 284 | self.writePixel(x, y + i, c) 285 | 286 | @classmethod 287 | def writeFastHLine(self, x, y, w, c): 288 | for i in range(w): 289 | self.writePixel(x + i, y, c) 290 | 291 | @classmethod 292 | def writeLine(self, x0, y0, x1, y1, c): 293 | self.GFX.line(x0, y0, x1, y1, c) 294 | 295 | @classmethod 296 | def endWrite(self): 297 | pass 298 | 299 | @classmethod 300 | def drawFastVLine(self, x, y, h, c): 301 | self.startWrite() 302 | self.writeFastVLine(x, y, h, c) 303 | self.endWrite() 304 | 305 | @classmethod 306 | def drawFastHLine(self, x, y, w, c): 307 | self.startWrite() 308 | self.writeFastHLine(x, y, w, c) 309 | self.endWrite() 310 | 311 | @classmethod 312 | def fillRect(self, x, y, w, h, c): 313 | self.startWrite() 314 | self.writeFillRect(x, y, w, h, c) 315 | self.endWrite() 316 | 317 | @classmethod 318 | def fillScreen(self, c): 319 | self.fillRect(0, 0, self.width(), self.height(), c) 320 | 321 | @classmethod 322 | def drawLine(self, x0, y0, x1, y1, c): 323 | self.startWrite() 324 | self.writeLine(x0, y0, x1, y1, c) 325 | self.endWrite() 326 | 327 | @classmethod 328 | def drawRect(self, x, y, w, h, c): 329 | self.GFX.rect(x, y, w, h, c) 330 | 331 | @classmethod 332 | def drawCircle(self, x, y, r, c): 333 | self.GFX.circle(x, y, r, c) 334 | 335 | @classmethod 336 | def fillCircle(self, x, y, r, c): 337 | self.GFX.fill_circle(x, y, r, c) 338 | 339 | @classmethod 340 | def drawTriangle(self, x0, y0, x1, y1, x2, y2, c): 341 | self.GFX.triangle(x0, y0, x1, y1, x2, y2, c) 342 | 343 | @classmethod 344 | def fillTriangle(self, x0, y0, x1, y1, x2, y2, c): 345 | self.GFX.fill_triangle(x0, y0, x1, y1, x2, y2, c) 346 | 347 | @classmethod 348 | def drawRoundRect(self, x, y, q, h, r, c): 349 | self.GFX.round_rect(x, y, q, h, r, c) 350 | 351 | @classmethod 352 | def fillRoundRect(self, x, y, q, h, r, c): 353 | self.GFX.fill_round_rect(x, y, q, h, r, c) 354 | 355 | @classmethod 356 | def setTextSize(self, s): 357 | self.textSize = s 358 | 359 | @classmethod 360 | def setFont(self, f): 361 | self.GFX.font = f 362 | 363 | @classmethod 364 | def printText(self, x, y, s, c=BLACK): 365 | self.GFX._very_slow_text(x, y, s, self.textSize, c) 366 | 367 | @classmethod 368 | def drawBitmap(self, x, y, data, w, h, c=BLACK): 369 | byteWidth = (w + 7) // 8 370 | byte = 0 371 | self.startWrite() 372 | for j in range(h): 373 | for i in range(w): 374 | if i & 7: 375 | byte <<= 1 376 | else: 377 | byte = data[j * byteWidth + i // 8] 378 | if byte & 0x80: 379 | self.writePixel(x + i, y + j, c) 380 | self.endWrite() 381 | 382 | @classmethod 383 | def drawColorImage(self, x, y, w, h, buf): 384 | scaled_w = int(-(-(w / 4.0) // 1)) 385 | for i in range(h): 386 | for j in range(scaled_w): 387 | self.writePixel(4 * j + x, i + y, (buf[scaled_w * i + j] & 0xC0) >> 6) 388 | if 4 * j + x + 1 < w: 389 | self.writePixel(4 * j + x + 1, i + y, (buf[scaled_w * i + j] & 0x30) >> 4) 390 | if 4 * j + x + 2 < w: 391 | self.writePixel(4 * j + x + 2, i + y, (buf[scaled_w * i + j] & 0x0C) >> 2) 392 | if 4 * j + x + 3 < w: 393 | self.writePixel(4 * j + x + 3, i + y, (buf[scaled_w * i + j] & 0x03)) 394 | -------------------------------------------------------------------------------- /mcp23017.py: -------------------------------------------------------------------------------- 1 | # MicroPython driver the MCP23017 GPIO expander 2 | # Contributed by: https://github.com/tve 3 | # Copyright © 2020 by Thorsten von Eicken 4 | from machine import Pin as mPin 5 | from micropython import const 6 | 7 | # MCP23017 registers - defined as const(), which makes them module-global 8 | IODIR = const(0) 9 | IOCON = const(0xA) 10 | GPPU = const(0xC) 11 | GPIO = const(0x12) 12 | OLAT = const(0x14) 13 | 14 | 15 | # MCP23017 is a minimal driver for an 16-bit I2C I/O expander 16 | class MCP23017: 17 | def __init__(self, i2c, addr=0x20): 18 | self.i2c = i2c 19 | self.addr = addr 20 | self.write(IOCON, 0x00) 21 | self.write2(IODIR, 0xFF, 0xFF) # all inputs 22 | self.gpio0 = 0 23 | self.gpio1 = 0 24 | self.write2(GPIO, 0, 0) 25 | 26 | # read an 8-bit register, internal method 27 | def read(self, reg): 28 | return self.i2c.readfrom_mem(self.addr, reg, 1)[0] 29 | 30 | # write an 8-bit register, internal method 31 | def write(self, reg, v): 32 | self.i2c.writeto_mem(self.addr, reg, bytes((v,))) 33 | 34 | # write two 8-bit registers, internal method 35 | def write2(self, reg, v1, v2): 36 | self.i2c.writeto_mem(self.addr, reg, bytes((v1, v2))) 37 | 38 | # writebuf writes multiple bytes to the same register 39 | def writebuf(self, reg, v): 40 | self.i2c.writeto_mem(self.addr, reg, v) 41 | 42 | # bit reads or sets a bit in a register, caching the gpio register for performance 43 | def bit(self, reg, num, v=None): 44 | if v is None: 45 | data = self.read(reg) 46 | if reg == GPIO: 47 | self.gpio0 = data 48 | elif reg == GPIO + 1: 49 | self.gpio1 = data 50 | return (data >> num) & 1 51 | else: 52 | mask = 0xFF ^ (1 << num) 53 | if reg == GPIO: 54 | self.gpio0 = (self.gpio0 & mask) | ((v & 1) << num) 55 | self.write(reg, self.gpio0) 56 | elif reg == GPIO + 1: 57 | self.gpio1 = (self.gpio1 & mask) | ((v & 1) << num) 58 | self.write(reg, self.gpio1) 59 | else: 60 | data = (self.read(reg) & mask) | ((v & 1) << num) 61 | self.write(reg, data) 62 | 63 | def pin(self, num, mode=mPin.IN, pull=None, value=None): 64 | return Pin(self, num, mode, pull, value) 65 | 66 | 67 | # Pin implements a minimal machine.Pin look-alike for pins on the MCP23017 68 | class Pin: 69 | def __init__(self, mcp23017, num, mode=mPin.IN, pull=None, value=None): 70 | self.bit = mcp23017.bit 71 | incr = num >> 3 # bank selector 72 | self.gpio = GPIO + incr 73 | self.num = num = num & 0x7 74 | if value is not None: 75 | self.bit(self.gpio, num, value) 76 | self.bit(IODIR + incr, num, 1 if mode == mPin.IN else 0) 77 | self.bit(GPPU + incr, num, 1 if pull == mPin.PULL_UP else 0) 78 | 79 | # value reads or write a pin value (0 or 1) 80 | def value(self, v=None): 81 | if v is None: 82 | return self.bit(self.gpio, self.num) 83 | else: 84 | self.bit(self.gpio, self.num, v) 85 | 86 | __call__ = value 87 | -------------------------------------------------------------------------------- /shapes.py: -------------------------------------------------------------------------------- 1 | # Copyright © 2020 by Thorsten von Eicken. 2 | 3 | # Shapes is intended to be a mix-in that adds methods to a class that is derived from the 4 | # MicroPython framebuf.FrameBuffer class. It adds methods to draw circles, rounded rectangles 5 | # etc. All the code is cobbled together from elsewhere, please refer to the embedded copyright 6 | # notices for the exact provenance. 7 | # Methods in Shapes call self.pixel, self.line, self.hline, and self.vline, so these must be 8 | # provided by the class that Shapes is mixed into. 9 | class Shapes: 10 | 11 | # __mix_me_in adds the methods of this class to another class. Typical usage is to put 12 | # something like Shapes.__mix_me_in(MyClass) after the class definition. 13 | @classmethod 14 | def __mix_me_in(cls, target): 15 | for func in dir(cls): 16 | if not callable(getattr(cls, func)) or func.startswith("__"): 17 | continue 18 | setattr(target, func, getattr(cls, func)) 19 | 20 | # The following shapes are adapted from https://github.com/peterhinch/micropython-epaper 21 | # Copyright 2015 Peter Hinch 22 | # 23 | # Licensed under the Apache License, Version 2.0 (the "License") you may not use this 24 | # file except in compliance with the License. You may obtain a copy of the License at: 25 | # 26 | # http:#www.apache.org/licenses/LICENSE-2.0 27 | # 28 | # Unless required by applicable law or agreed to in writing, software distributed under 29 | # the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 30 | # KIND, either express or implied. See the License for the specific language governing 31 | # permissions and limitations under the License. 32 | # Code translated and developed from https://developer.mbed.org/users/dreschpe/code/EaEpaper/ 33 | 34 | def circle(self, x0, y0, r, color): # Single pixel circle 35 | x = -r 36 | y = 0 37 | err = 2 - 2 * r 38 | while x <= 0: 39 | self.pixel(x0 - x, y0 + y, color) 40 | self.pixel(x0 + x, y0 + y, color) 41 | self.pixel(x0 + x, y0 - y, color) 42 | self.pixel(x0 - x, y0 - y, color) 43 | e2 = err 44 | if e2 <= y: 45 | y += 1 46 | err += y * 2 + 1 47 | if -x == y and e2 <= x: 48 | e2 = 0 49 | if e2 > x: 50 | x += 1 51 | err += x * 2 + 1 52 | 53 | def fill_circle(self, x0, y0, r, color): # Draw filled circle 54 | x0, y0, r = int(x0), int(y0), int(r) 55 | x = -r 56 | y = 0 57 | err = 2 - 2 * r 58 | while x <= 0: 59 | self.vline(x0 - x, y0 - y, 2*y+1, color) 60 | self.vline(x0 + x, y0 - y, 2*y+1, color) 61 | e2 = err 62 | if e2 <= y: 63 | y += 1 64 | err += y * 2 + 1 65 | if -x == y and e2 <= x: 66 | e2 = 0 67 | if e2 > x: 68 | x += 1 69 | err += x * 2 + 1 70 | 71 | # The following shapes are adapted from https://github.com/adafruit/Adafruit_CircuitPython_GFX 72 | # The MIT License (MIT) 73 | # 74 | # Copyright (c) 2018 Kattni Rembor for Adafruit Industries 75 | # 76 | # Permission is hereby granted, free of charge, to any person obtaining a copy 77 | # of this software and associated documentation files (the "Software"), to deal 78 | # in the Software without restriction, including without limitation the rights 79 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 80 | # copies of the Software, and to permit persons to whom the Software is 81 | # furnished to do so, subject to the following conditions: 82 | # 83 | # The above copyright notice and this permission notice shall be included in 84 | # all copies or substantial portions of the Software. 85 | # 86 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 87 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 88 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 89 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 90 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 91 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 92 | # THE SOFTWARE. 93 | 94 | def triangle(self, x0, y0, x1, y1, x2, y2, color): 95 | """Triangle drawing function. Will draw a single pixel wide triangle 96 | around the points (x0, y0), (x1, y1), and (x2, y2).""" 97 | self.line(x0, y0, x1, y1, color) 98 | self.line(x1, y1, x2, y2, color) 99 | self.line(x2, y2, x0, y0, color) 100 | 101 | def fill_triangle(self, x0, y0, x1, y1, x2, y2, color): 102 | """Filled triangle drawing function. Will draw a filled triangle around 103 | the points (x0, y0), (x1, y1), and (x2, y2).""" 104 | if y0 > y1: 105 | y0, y1 = y1, y0 106 | x0, x1 = x1, x0 107 | if y1 > y2: 108 | y2, y1 = y1, y2 109 | x2, x1 = x1, x2 110 | if y0 > y1: 111 | y0, y1 = y1, y0 112 | x0, x1 = x1, x0 113 | a = 0 114 | b = 0 115 | y = 0 116 | last = 0 117 | if y0 == y2: 118 | a = x0 119 | b = x0 120 | if x1 < a: 121 | a = x1 122 | elif x1 > b: 123 | b = x1 124 | if x2 < a: 125 | a = x2 126 | elif x2 > b: 127 | b = x2 128 | self.hline(a, y0, b - a + 1, color) 129 | return 130 | dx01 = x1 - x0 131 | dy01 = y1 - y0 132 | dx02 = x2 - x0 133 | dy02 = y2 - y0 134 | dx12 = x2 - x1 135 | dy12 = y2 - y1 136 | if dy01 == 0: 137 | dy01 = 1 138 | if dy02 == 0: 139 | dy02 = 1 140 | if dy12 == 0: 141 | dy12 = 1 142 | sa = 0 143 | sb = 0 144 | if y1 == y2: 145 | last = y1 146 | else: 147 | last = y1 - 1 148 | for y in range(y0, last + 1): 149 | a = x0 + sa // dy01 150 | b = x0 + sb // dy02 151 | sa += dx01 152 | sb += dx02 153 | if a > b: 154 | a, b = b, a 155 | self.hline(a, y, b - a + 1, color) 156 | sa = dx12 * (y - y1) 157 | sb = dx02 * (y - y0) 158 | while y <= y2: 159 | a = x1 + sa // dy12 160 | b = x0 + sb // dy02 161 | sa += dx12 162 | sb += dx02 163 | if a > b: 164 | a, b = b, a 165 | self.hline(a, y, b - a + 1, color) 166 | y += 1 167 | 168 | def round_rect(self, x0, y0, width, height, radius, color): 169 | """Rectangle with rounded corners drawing function. 170 | This works like a regular rect though! if radius = 0 171 | Will draw the outline of a rextabgle with rounded corners with (x0,y0) at the top left""" 172 | # shift to correct for start point location 173 | x0 += radius 174 | y0 += radius 175 | 176 | # ensure that the radius will only ever half of the shortest side or less 177 | radius = int(min(radius, width / 2, height / 2)) 178 | 179 | if radius: 180 | f = 1 - radius 181 | ddF_x = 1 182 | ddF_y = -2 * radius 183 | x = 0 184 | y = radius 185 | self.vline(x0 - radius, y0, height - 2 * radius + 1, color) # left 186 | self.vline(x0 + width - radius, y0, height - 2 * radius + 1, color) # right 187 | self.hline(x0, y0 + height - radius + 1, width - 2 * radius + 1, color) # bottom 188 | self.hline(x0, y0 - radius, width - 2 * radius + 1, color) # top 189 | while x < y: 190 | if f >= 0: 191 | y -= 1 192 | ddF_y += 2 193 | f += ddF_y 194 | x += 1 195 | ddF_x += 2 196 | f += ddF_x 197 | # angle notations are based on the unit circle and in diection of being drawn 198 | 199 | # top left 200 | self.pixel(x0 - y, y0 - x, color) # 180 to 135 201 | self.pixel(x0 - x, y0 - y, color) # 90 to 135 202 | # top right 203 | self.pixel(x0 + x + width - 2 * radius, y0 - y, color) # 90 to 45 204 | self.pixel(x0 + y + width - 2 * radius, y0 - x, color) # 0 to 45 205 | # bottom right 206 | self.pixel( 207 | x0 + y + width - 2 * radius, y0 + x + height - 2 * radius, color 208 | ) # 0 to 315 209 | self.pixel( 210 | x0 + x + width - 2 * radius, y0 + y + height - 2 * radius, color 211 | ) # 270 to 315 212 | # bottom left 213 | self.pixel(x0 - x, y0 + y + height - 2 * radius, color) # 270 to 255 214 | self.pixel(x0 - y, y0 + x + height - 2 * radius, color) # 180 to 225 215 | 216 | def fill_round_rect(self, x0, y0, width, height, radius, color): 217 | """Filled circle drawing function. Will draw a filled circule with 218 | center at x0, y0 and the specified radius.""" 219 | # shift to correct for start point location 220 | x0 += radius 221 | y0 += radius 222 | 223 | # ensure that the radius will only ever half of the shortest side or less 224 | radius = int(min(radius, width / 2, height / 2)) 225 | 226 | self.fill_rect(x0, y0 - radius, width - 2 * radius + 2, height + 2, color) 227 | 228 | if radius: 229 | f = 1 - radius 230 | ddF_x = 1 231 | ddF_y = -2 * radius 232 | x = 0 233 | y = radius 234 | while x < y: 235 | if f >= 0: 236 | y -= 1 237 | ddF_y += 2 238 | f += ddF_y 239 | x += 1 240 | ddF_x += 2 241 | f += ddF_x 242 | # part notation starts with 0 on left and 1 on right, and direction is noted 243 | # top left 244 | self.vline(x0 - y, y0 - x, 2 * x + 1 + height - 2 * radius, color) # 0 to .25 245 | self.vline(x0 - x, y0 - y, 2 * y + 1 + height - 2 * radius, color) # .5 to .25 246 | # top right 247 | self.vline( 248 | x0 + x + width - 2 * radius, y0 - y, 2 * y + 1 + height - 2 * radius, color 249 | ) # .5 to .75 250 | self.vline( 251 | x0 + y + width - 2 * radius, y0 - x, 2 * x + 1 + height - 2 * radius, color 252 | ) # 1 to .75 253 | -------------------------------------------------------------------------------- /soldered_logo.py: -------------------------------------------------------------------------------- 1 | soldered_logo = bytearray( 2 | b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\xfc\x3f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\xf0\x0f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\xc0\x07\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\x80\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xfe\x00\x00\x7f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xf8\x00\x00\x1f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xf0\x00\x00\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xc0\x01\x80\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xc0\x07\xe0\x00\xff\xfe\x03\xff\xf8\x07\xfe\x07\xff\xc0\x0f\xff\x80\x00\x78\x00\xff\xf0\x00\x1e\x00\x7f\xe0\xc0\x1f\xf0\x00\xff\xf8\x00\xff\xe0\x01\xfe\x07\xff\xc0\x00\xff\x80\x00\x78\x00\x0f\xf0\x00\x0e\x00\x0f\xe0\xc0\x3f\xfc\x00\xff\xf0\x00\x3f\x80\x00\xfe\x07\xff\xc0\x00\x3f\x80\x00\x78\x00\x03\xf0\x00\x0e\x00\x03\xe0\xc0\xfe\x7e\x00\xff\xe0\x00\x3f\x00\x00\x7e\x07\xff\xc0\x00\x1f\x80\x00\x78\x00\x01\xf0\x00\x0e\x00\x00\xe0\xc0\xfc\x3f\x01\xff\xc0\x00\x3f\x00\x00\x3e\x07\xff\xc0\x00\x0f\x80\x00\x78\x00\x01\xf0\x00\x0e\x00\x00\x60\xc0\xf8\x0f\x81\xff\xc0\x00\x7e\x00\x80\x1e\x07\xff\xc0\x00\x0f\x80\x00\x78\x1c\x00\xf0\x00\x1e\x00\x00\x60\xc0\xf8\x03\xff\xff\x80\xfc\xfe\x03\xf0\x1e\x07\xff\xc0\xf8\x07\x81\xff\xf8\x1f\x80\xf0\x3f\xfe\x07\xc0\x20\xc0\xf8\x01\xff\xff\x80\xff\xfc\x07\xf8\x0e\x07\xff\xc0\xfc\x07\x81\xff\xf8\x1f\xc0\xf0\x3f\xfe\x07\xe0\x20\xc0\xf8\x00\x7f\xff\x80\xff\xfc\x0f\xf8\x0e\x07\xff\xc0\xfe\x03\x81\xff\xf8\x1f\xc0\xf0\x3f\xfe\x07\xf0\x00\xc0\xfc\x00\x1f\xff\x80\x7f\xfc\x0f\xfc\x0e\x07\xff\xc0\xfe\x03\x81\xff\xf8\x1f\xc0\xf0\x3f\xfe\x07\xf0\x00\xc0\x7e\x00\x07\xff\xc0\x0f\xf8\x0f\xfc\x0e\x07\xff\xc0\xff\x03\x80\x00\xf8\x1f\x80\xf0\x00\x3e\x07\xf0\x00\xc0\x1f\x80\x03\xff\xc0\x03\xf8\x0f\xfc\x0e\x07\xff\xc0\xff\x03\x80\x00\xf8\x1f\x00\xf0\x00\x3e\x07\xf8\x00\xc0\x0f\xc0\x01\xff\xe0\x00\xf8\x0f\xfc\x0e\x07\xff\xc0\xff\x03\x80\x00\xf8\x00\x01\xf0\x00\x3e\x07\xf8\x00\xc0\x03\xf0\x01\xff\xf0\x00\x78\x0f\xfc\x0e\x07\xff\xc0\xff\x03\x80\x00\xf8\x00\x01\xf0\x00\x3e\x07\xf8\x00\xc0\x00\xfc\x01\xff\xfc\x00\x38\x0f\xfc\x0e\x07\xff\xc0\xff\x03\x80\x00\xf8\x00\x03\xf0\x00\x3e\x07\xf8\x00\xf0\x00\x3f\x01\xff\xff\x00\x18\x0f\xfc\x0e\x07\xff\xc0\xff\x03\x80\x01\xf8\x00\x0f\xf0\x00\x3e\x07\xf8\x00\xfc\x00\x1f\x01\xff\xff\xc0\x1c\x0f\xfc\x0e\x07\xff\xc0\xff\x03\x81\xff\xf8\x00\x0f\xf0\x3f\xfe\x07\xf0\x00\xfe\x00\x1f\x01\xff\xff\xf0\x1c\x0f\xf8\x0e\x03\xff\xc0\xfe\x03\x81\xff\xf8\x1c\x07\xf0\x3f\xfe\x07\xf0\x00\xff\x80\x1f\x01\xff\xff\xf8\x1c\x07\xf8\x0e\x01\xff\xc0\xfe\x07\x81\xff\xf8\x1c\x07\xf0\x3f\xfe\x07\xe0\x20\xf3\xe0\x1f\x01\xff\xe7\xf8\x1c\x03\xf0\x1e\x00\xff\xc0\xfc\x07\x81\xff\xf8\x1e\x03\xf0\x3f\xfe\x07\xe0\x20\xc0\xf8\x1f\x01\xff\xc1\xf0\x1e\x01\xe0\x1f\x00\x01\xc0\xf0\x07\x81\xff\xf8\x1e\x03\xf0\x3f\xfe\x07\x80\x60\x80\xfc\x1f\x01\xff\x80\x00\x1e\x00\x00\x3f\x80\x01\xc0\x00\x0f\x80\x00\x38\x1f\x01\xf0\x00\x0e\x00\x00\x60\x80\x7f\x7f\x01\xff\x80\x00\x3f\x00\x00\x3f\xc0\x01\xc0\x00\x1f\x80\x00\x38\x1f\x01\xf0\x00\x0e\x00\x00\xe0\x00\x1f\xfc\x01\xff\x80\x00\x3f\x80\x00\x7f\xe0\x01\xc0\x00\x3f\x80\x00\x38\x1f\x80\xf0\x00\x0e\x00\x01\xe0\x00\x0f\xf8\x01\xff\xc0\x00\xff\xc0\x00\xff\xf0\x01\xc0\x00\x7f\x80\x00\x38\x1f\x80\xf0\x00\x0e\x00\x03\xe0\x80\x03\xe0\x01\xff\xf0\x01\xff\xf0\x03\xff\xf8\x01\xc0\x03\xff\x80\x00\x38\x1f\xc0\x70\x00\x0e\x00\x1f\xe0\x80\x00\x80\x03\xff\xff\x1f\xff\xfe\x3f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xc0\x00\x00\x07\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xfc\x00\x00\x1f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\x00\x00\x7f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\xc0\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\xe0\x03\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\xf8\x0f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\xfe\x3f\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xe0" 3 | ) --------------------------------------------------------------------------------