Skip to content

clach04/cyd_clocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cyd_clocks

CYD clock experiments https://github.com/clach04/cyd_clocks

https://github.com/micropython/micropython code written for use with ESP32-2432S028R - an esp32 based device with built-in screen.

NOTE some scripts expect/need/rely on https://github.com/clach04/MicroWiFiManager/tree/mine

Firmware recommendation:

Device Information

Hardware notes, printed ids:

ESP32-2432S028

on ESP32:

  • ESP-WROOM 32
  • FCC ID: 2AC7Z-ESP-WROOM32

LCD has printed TPM408-2.8

MicroPython

Relies on Micropython with library/libraries:

The code in this repo was originally written to support MicroPython 1.19.1, but may (soon) require MicroPython 1.24.1+ (Nano GUI expects asyncio, rather than the older uasyncio namespace).

NOTE on my device color reproduction is improved with changes in ILI9341 init, either pass in gamma=False or modify driver with changes from https://github.com/de-dh/ESP32-Cheap-Yellow-Display-Micropython-LVGL/tree/main/demo_no_lvgl:

self.write_cmd(self.GAMMASET, 0x02)
sleep(.1)
self.write_cmd(self.GAMMASET, 0x01)
# TODO another; sleep(.1)

Demos

MicroPython Demos

Recommend using Thonny or mpremote (pip install mpremote)

  • hw_info.py - Dump device information out to the serial port

    mpremote connect com5 mount .
    import hw_info
    # Then issue CTRL-] (to exit) or CTRL-D (to restart)
    
  • wifi_setup.py - Connect to wifi quickly, suitable for then issuing mip to install packages

Nano GUI

WARNING fonts should include; "0123456789 :-"

See https://github.com/peterhinch/micropython-nano-gui?tab=readme-ov-file#13-quick-start for how to gets started (use mpremote and try a demo)

  • color_setup.py - TODO requires EDIT setup/config for using CYD1 and CYD2 with MicroPython Nano GUI https://github.com/peterhinch/micropython-nano-gui - see https://github.com/peterhinch/micropython-nano-gui/blob/master/setup_examples/ili9341_esp32_2432S028r.py
    • use with demos like gui.demos.aclock_large - https://github.com/peterhinch/micropython-nano-gui/blob/master/gui/demos/aclock_large.py

    • nano_rgb_test.py - color and screen size/direction/orientation test/demo

    • nano_mono_test.py - 2 color screen size/direction/orientation test/demo

    • nano_rainbow_test.py - simple full screen rainbow color demo, also see rainbow_test.py

      # In a micropython-nano-gui checkout (also with some of these demos)
      mpremote connect com5 mount .
      # import sys ; sys.path[2] = 'lib'  # https://github.com/micropython/micropython/issues/9734
      import nano_rainbow_test
      
    • nano_helloworld.py - text/font demo - uses framebuffer and nano labels

    • nano_bitmap_fullscreen.py - load and display bitmap image "fullscreen.bin", also see bitmap_fullscreen.py

    • nano_wifi_clock_timer.py - incomplete WIP nano version of wifi_clock_timer.py

    • nano_wifi_theme_clock.py - incomplete WIP - theme support #39

      mpremote connect com5 mount .
      import sys ; sys.path[2] = 'lib' ; import nano_wifi_theme_clock
      # NOTE very slow (USB/serial) image/font transfer compared with local IO
      
      # Alternatively, all-in-one:
      mpremote connect com5 mount . exec "import sys ; sys.path[2] = 'lib' ; import nano_wifi_theme_clock"
      
    • image_converter.py - PIL/Pillow image converter for nano-GUI, only supports 4-bit and expects pallete to be setup already (alternative to img_cvt.py)

    • create_pallette_nano_4bit.py - PIL/Pillow 16 color (4-bit) pallete generater, saves a PNG file - see #40

    • nano_4bit_pallette.py - PIL/Pillow 16 color (4-bit) pallete definitions

Simple install:

  # where lib directory includes nano-gui
  mpremote connect com5 cp -r lib :
  mpremote connect com5 cp -r thme.json :
  mpremote connect com5 cp -r fullscreen_4bit.bin :
  mpremote connect com5 cp -r clock.json :
  mpremote connect com5 cp -r nano_wifi_theme_clock.py :
  mpremote connect com5 cp -r posix_tz.py :
  mpremote connect com5 cp -r color_setup.py :

ili9341 driver

Needs https://github.com/rdagger/micropython-ili9341

TODO create equivilent of nano_rgb_test.py

  • cyd_wrap.py - simple wrapper NOTE look for EDIT_ME and modify for your device

    • rainbow_test.py - simple full screen rainbow color demo, also see nano_rainbow_test.py

      mpremote connect com5 mount .
      import rainbow_test
      # NOTE good chance this will fail due to out of memory; MemoryError: memory allocation failed, allocating ABC bytes
      
    • rainbow_test_speaker.py - duplicated rainbow_test.py with simple tone playing

    • bitmap_fullscreen.py - load and display bitmap image "fullscreen_320x240_rgb565.raw", can be created from sample in images directory, also see nano_bitmap_fullscreen.py

    • font_clock_timer_paint.py - simple font based clock

    • cyd_demo.py - simple hardware demo. screen, RGB LED, light sensor, and touch screen

  • wifi_clock_timer.py - WiFi clock. no touch screen or button control, configure network via SClock said, by opening http://192.168.4.1 (DNS captive portal doesn't work well). NOTE http not https.

  • tiny_8x8_clock_always_paint.py - 8x8 font, not really readable - basic test including ISO date display

  • font_clock_always_paint.py - 12x24 font, still too small - basic test

  • font_clock_always_paint_UMB.py - 43x61 font (Ubuntu Mono Bold size 72, UbuntuMonoBold43x61numbers.c), currently too slow to be reliable for 1 second accuracy (needs accurate sleep math)

  • clock-digits-4.py - small 7-segment style digit, still too small but larger than above - basic test - NOTE Work In Progress, has painting issues

  • 01-rainbow-test.py - simple full screen rainbow color demo

  • demo_pbm.py - invader sprite/gfx blit demo - NOTE needs pbm https://github.com/rdagger/micropython-ili9341/blob/master/images/invaders48x36.pbm

CircuitPython Demos

In directory circuitpython.

  • hw_info_cp.py - Limited CircuitPython version of hw_info.py - Dump device information out to the serial port and screen
  • bitmap_test.py - bitmap / picture / photo fullscreen demo
    • uses 240x320.bmp which is EBU_Colorbars converted into 24-bit Windows BitMap

Test Images

Test cards from https://en.wikipedia.org/wiki/Test_card

License either Public Domain or Creative Commons

See images.

Also see:

Also see

esp registry https://components.espressif.com/

About

CYD clock experiments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published