Run LVGL + Micropython in Cheap Yellow Display (CYD)

Step 1

git clone https://github.com/lvgl-micropython/lvgl_micropython.git
cd lvgl_micropython
python3 make.py esp32 clean \
  --flash-size=4 \
  BOARD=ESP32_GENERIC \
  DISPLAY=ili9341
esptool.py erase_flash
esptool.py write_flash 0 build/lvgl_micropy_ESP32_GENERIC-4.bin
'''
Custom Driver xpt2046_cyd and MPY-LVGL build from
https://stefan.box2code.de/2023/11/18/esp32-grafik-mit-lvgl-und-micropython/

Running on cheap yellow display with TWO USB Ports
--> https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/blob/main/cyd.md
'''
import lvgl as lv
import time
import st7789
from machine import Pin, SoftSPI

# Initialize LVGL
lv.init()

# Initialize SoftSPI for ST7789 display
spi = SoftSPI(
    baudrate=10000000,  # 10 MHz, suitable for SoftSPI
    polarity=0,
    phase=0,
    sck=Pin(18),
    mosi=Pin(23),
    miso=Pin(19)  # MISO not needed for ST7789, included for completeness
)

# Initialize ST7789 display driver
display = st7789.ST7789(
    spi=spi,
    dc=Pin(2, Pin.OUT),
    cs=Pin(15, Pin.OUT),
    rst=Pin(4, Pin.OUT),
    backlight=Pin(27, Pin.OUT),  # Backlight pin
    rotation=0
)
display.init()

# Register the display driver with LVGL
disp_buf = lv.disp_draw_buf_t()
buf = bytearray(240 * 10)  # Buffer for 10 rows (240 pixels wide)
disp_buf.init(buf, None, len(buf) // 4)
disp_drv = lv.disp_drv_t()
disp_drv.init()
disp_drv.draw_buf = disp_buf
disp_drv.flush_cb = display.flush
disp_drv.hor_res = 240  # Set resolution here for LVGL
disp_drv.ver_res = 320
disp_drv.register()

num = 0  # Used for callback

def enable(el):
    if el.has_state(lv.STATE.DISABLED):
        el.clear_state(lv.STATE.DISABLED)

def disable(el):
    if not el.has_state(lv.STATE.DISABLED):
        el.add_state(lv.STATE.DISABLED)

def largeFont(el):
    el.set_style_text_font(lv.font_montserrat_16, 0)

def callback(s):
    global num
    if s == 'Prev':
        num -= 1
    elif s == 'Next':
        num += 1
    valueLbl.set_text('Count: ' + str(num))

# Get reference to active screen for drawing
scr = lv.screen_active()
scr.set_style_bg_color(lv.color_white(), lv.PART.MAIN)

# Create label and center it on screen
valueLbl = lv.label(scr)
largeFont(valueLbl)
valueLbl.set_text('Count: ' + str(num))
valueLbl.center()

# Create Button with icon and text and add callback
prevBtn = lv.btn(scr)
prevBtn.set_size(80, 40)
prevBtn.align_to(valueLbl, lv.ALIGN.OUT_LEFT_MID, -20, 0)
prevBtn.add_event_cb(lambda e: callback('Prev'), lv.EVENT.CLICKED, None)
# Assign label to button
prevBtnLbl = lv.label(prevBtn)
prevBtnLbl.set_text(lv.SYMBOL.PREV + ' Prev')
prevBtnLbl.center()

nextBtn = lv.btn(scr)
nextBtn.set_size(80, 40)
nextBtn.align_to(valueLbl, lv.ALIGN.OUT_RIGHT_MID, 20, 0)
nextBtn.add_event_cb(lambda e: callback('Next'), lv.EVENT.CLICKED, None)

nextBtnLbl = lv.label(nextBtn)
nextBtnLbl.set_text('Next ' + lv.SYMBOL.NEXT)
nextBtnLbl.center()

# Main loop to handle LVGL tasks
while True:
    lv.task_handler()
    time.sleep_ms(10)  # Update every 10ms for smooth rendering

Download All Files in below links, or by the attachment in this posts

ILI9341 Display Driver

Download ili9341.py from: github.com/rdagger/micropython-ili9341.

Save it to the CYD using Thonny (View > Files > Upload to /).

XPT2046 Touchscreen Driver

Download xpt2046.py from: github.com/rdagger/micropython-ili9341.

Upload it to the CYD.

Font Library

For custom fonts, download xglcd_font.py and font files (e.g., Unispace12x24.c) from: github.com/rdagger/micropython-ili9341.

Create a /fonts directory on the CYD and upload the font files.

CYD-Specific Library (Optional)

For simplified control, use the cydr.py library from: github.com/jtobinart/MicroPython_CYD_ESP32-2432S028R.


Unispace12x24.c

https://github.com/rdagger/micropython-ili9341/blob/master/fonts/Unispace12x24.c

Run it

mpremote cp cydr.py :cydr.py
mpremote cp ili9341.py :ili9341.py
mpremote cp xglcd_font.py :xglcd_font.py
mpremote cp xpt2046.py :xpt2046.py
mpremote mkdir fonts
mpremote cp Unispace12x24.c :fonts/Unispace12x24.c
mpremote cp main.py :main.py
mpremote exec "import main"

Example 1 : Animation.py

from machine import Pin, SPI
from ili9341 import Display, color565
import time

# Initialize SPI for ILI9341 display
display_spi = SPI(1, baudrate=60000000, sck=Pin(14), mosi=Pin(13))
display = Display(display_spi, dc=Pin(2), cs=Pin(15), rst=Pin(15), width=320, height=240, rotation=90)

# Turn on backlight
backlight = Pin(21, Pin.OUT)
backlight.on()

# Clear display (white background)
display.clear(color565(255, 255, 255))

# Animation parameters
rect_width = 30
rect_height = 30
x = 0
y = 0
dx = 6  # Increased speed
dy = 6  # Increased speed
rect_color = color565(255, 0, 0)  # Red rectangle
bg_color = color565(255, 255, 255)  # White background

# Animation loop
while True:
    # Clear previous rectangle (minimize cleared area)
    display.fill_rectangle(x, y, rect_width, rect_height, bg_color)
    
    # Update position
    x += dx
    y += dy
    
    # Bounce off edges
    if x <= 0 or x >= 320 - rect_width:
        dx = -dx
    if y <= 0 or y >= 240 - rect_height:
        dy = -dy
    
    # Draw new rectangle
    display.fill_rectangle(x, y, rect_width, rect_height, rect_color)
    
    # Reduced delay for faster animation
    time.sleep(0.02)  # ~50 FPS

Example 2 : Animation_complex.py

from machine import Pin, SPI
from ili9341 import Display, color565
from xglcd_font import XglcdFont
import time
import math

# Initialize SPI and ILI9341 display
display_spi = SPI(1, baudrate=60000000, sck=Pin(14), mosi=Pin(13))
display = Display(display_spi, dc=Pin(2), cs=Pin(15), rst=Pin(15), width=320, height=240, rotation=90)

# Turn on backlight
backlight = Pin(21, Pin.OUT)
backlight.on()

# Clear display (black background for contrast)
display.clear(color565(0, 0, 0))

# Load font
unispace = XglcdFont('fonts/Unispace12x24.c', 12, 24)

# Shape parameters (2 rectangles)
shapes = [
    {'type': 'rect', 'x': 50, 'y': 50, 'w': 25, 'h': 25, 'dx': 5, 'dy': 3},  # Rectangle 1
    {'type': 'rect', 'x': 100, 'y': 80, 'w': 20, 'h': 20, 'dx': -4, 'dy': 4}   # Rectangle 2
]

# Text parameters
text = "CYD Demo!"
text_x = 0
text_dx = 3
text_color = color565(255, 255, 255)  # White text
bg_color = color565(0, 0, 0)  # Black background

# Color transition parameters
color_phase = 0
color_cycle_speed = 0.1  # Faster color change

# Animation loop
while True:
    # Clear previous text
    display.fill_rectangle(text_x, 0, unispace.measure_text(text), 24, bg_color)
    
    # Update text position
    text_x += text_dx
    if text_x <= 0 or text_x >= 320 - unispace.measure_text(text):
        text_dx = -text_dx
    
    # Draw text
    display.draw_text(text_x, 0, text, unispace, text_color)
    
    # Update color phase (simplified)
    color_phase = (color_phase + color_cycle_speed) % (2 * math.pi)
    r = int(127 * (1 + math.sin(color_phase)))
    g = int(127 * (1 + math.cos(color_phase)))
    b = 128  # Fixed blue for simplicity
    shape_color = color565(r, g, b)
    
    # Update and draw shapes
    for shape in shapes:
        # Clear previous shape
        display.fill_rectangle(shape['x'], shape['y'], shape['w'], shape['h'], bg_color)
        
        # Update position
        shape['x'] += shape['dx']
        shape['y'] += shape['dy']
        
        # Bounce off edges (avoid text area)
        if shape['x'] <= 0 or shape['x'] >= 320 - shape['w']:
            shape['dx'] = -shape['dx']
        if shape['y'] <= 24 or shape['y'] >= 240 - shape['h']:
            shape['dy'] = -shape['dy']
        
        # Draw new shape
        display.fill_rectangle(shape['x'], shape['y'], shape['w'], shape['h'], shape_color)
    
    # Delay for ~66 FPS
    time.sleep(0.015)

In mac, sometime arduino unable to write the program to cheap yellow display esp32, you can type the command manually

If you have this problem:

run: sigrok-cli --loglevel 5 -d fx2lafw --scan , it said failed to find the firmware file

So build this project and restart terminal, then you will success

git clone git://sigrok.org/sigrok-firmware-fx2lafw
cd sigrok-firmware-fx2lafw
./autogen.sh
./configure
make
sudo make install
sigrok-cli --driver fx2lafw:conn=20.59 -g Logic --samples 80 -O ascii:width=80:charset='_"\/'

It has no SoftI2C, so change

display = ssd1306.SSD1306_I2C(128, 64, SoftI2C(sda=Pin(20), scl=Pin(21)))

to

import time
from machine import Pin, I2C, SoftI2C
import ssd1306

display = ssd1306.SSD1306_I2C(128, 64, i2c) # Pass I2C object

display.fill(0)
display.text("Hello, World", 0, 0)
display.show()

time.sleep(100)

  1. git clone https://github.com/micropython/micropython.git
  2. cd micropython
  3. docker run -it -v .:/micropython --name micropython ubuntu
  4. apt-get update
  5. apt-get install -y gcc g++ make automake python3 git gcc-arm-none-eabi
  6. cd /micropython/mpy-cross
  7. make
  1. cd ../ports/stm32
  2. make BOARD=WEACT_F411_BLACKPILL submodules
  3. make BOARD=WEACT_F411_BLACKPILL
  1. exit docker
  2. in mac: brew install dfu-uril
  3. cd to micropython/ports/stm32
  4. st-info --probe
  5. st-flash erase
  6. st-flash --format ihex write build-WEACT_F411_BLACKPILL/firmware.hex

using st-flash is better then dfu-util because we don't need to put the board into dfu mode

  1. pip install mpremote
  2. mpremote
  3. mremote fs ls
  4. ctrl+] to exit

https://gitlab.quantr.hk/quantr/toolchain/java-at28-programmer

https://gitlab.quantr.hk/example/arduino/at28-programmer

#
# MicroPython SH1106 OLED driver, I2C and SPI interfaces
#
# The MIT License (MIT)
#
# Copyright (c) 2016 Radomir Dopieralski (@deshipu),
#               2017-2021 Robert Hammelrath (@robert-hh)
#               2021 Tim Weber (@scy)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# Sample code sections for ESP8266 pin assignments
# ------------ SPI ------------------
# Pin Map SPI
#   - 3v - xxxxxx   - Vcc
#   - G  - xxxxxx   - Gnd
#   - D7 - GPIO 13  - Din / MOSI fixed
#   - D5 - GPIO 14  - Clk / Sck fixed
#   - D8 - GPIO 4   - CS (optional, if the only connected device)
#   - D2 - GPIO 5   - D/C
#   - D1 - GPIO 2   - Res
#
# for CS, D/C and Res other ports may be chosen.
#
# from machine import Pin, SPI
# import sh1106

# spi = SPI(1, baudrate=1000000)
# display = sh1106.SH1106_SPI(128, 64, spi, Pin(5), Pin(2), Pin(4))
# display.sleep(False)
# display.fill(0)
# display.text('Testing 1', 0, 0, 1)
# display.show()
#
# --------------- I2C ------------------
#
# Pin Map I2C
#   - 3v - xxxxxx   - Vcc
#   - G  - xxxxxx   - Gnd
#   - D2 - GPIO 5   - SCK / SCL
#   - D1 - GPIO 4   - DIN / SDA
#   - D0 - GPIO 16  - Res
#   - G  - xxxxxx     CS
#   - G  - xxxxxx     D/C
#
# Pin's for I2C can be set almost arbitrary
#
# from machine import Pin, I2C
# import sh1106
#
# i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)
# display = sh1106.SH1106_I2C(128, 64, i2c, Pin(16), 0x3c)
# display.sleep(False)
# display.fill(0)
# display.text('Testing 1', 0, 0, 1)
# display.show()

from micropython import const
import utime as time
import framebuf


# a few register definitions
_SET_CONTRAST        = const(0x81)
_SET_NORM_INV        = const(0xa6)
_SET_DISP            = const(0xae)
_SET_SCAN_DIR        = const(0xc0)
_SET_SEG_REMAP       = const(0xa0)
_LOW_COLUMN_ADDRESS  = const(0x00)
_HIGH_COLUMN_ADDRESS = const(0x10)
_SET_PAGE_ADDRESS    = const(0xB0)


class SH1106(framebuf.FrameBuffer):

    def __init__(self, width, height, external_vcc, rotate=0):
        self.width = width
        self.height = height
        self.external_vcc = external_vcc
        self.flip_en = rotate == 180 or rotate == 270
        self.rotate90 = rotate == 90 or rotate == 270
        self.pages = self.height // 8
        self.bufsize = self.pages * self.width
        self.renderbuf = bytearray(self.bufsize)
        self.pages_to_update = 0
        self.delay = 0

        if self.rotate90:
            self.displaybuf = bytearray(self.bufsize)
            # HMSB is required to keep the bit order in the render buffer
            # compatible with byte-for-byte remapping to the display buffer,
            # which is in VLSB. Else we'd have to copy bit-by-bit!
            super().__init__(self.renderbuf, self.height, self.width,
                             framebuf.MONO_HMSB)
        else:
            self.displaybuf = self.renderbuf
            super().__init__(self.renderbuf, self.width, self.height,
                             framebuf.MONO_VLSB)

        # flip() was called rotate() once, provide backwards compatibility.
        self.rotate = self.flip
        self.init_display()

    # abstractmethod
    def write_cmd(self, *args, **kwargs): 
        raise NotImplementedError

    # abstractmethod
    def write_data(self,  *args, **kwargs):
        raise NotImplementedError

    def init_display(self):
        self.reset()
        self.fill(0)
        self.show()
        self.poweron()
        # rotate90 requires a call to flip() for setting up.
        self.flip(self.flip_en)

    def poweroff(self):
        self.write_cmd(_SET_DISP | 0x00)

    def poweron(self):
        self.write_cmd(_SET_DISP | 0x01)
        if self.delay:
            time.sleep_ms(self.delay)

    def flip(self, flag=None, update=True):
        if flag is None:
            flag = not self.flip_en
        mir_v = flag ^ self.rotate90
        mir_h = flag
        self.write_cmd(_SET_SEG_REMAP | (0x01 if mir_v else 0x00))
        self.write_cmd(_SET_SCAN_DIR | (0x08 if mir_h else 0x00))
        self.flip_en = flag
        if update:
            self.show(True) # full update

    def sleep(self, value):
        self.write_cmd(_SET_DISP | (not value))

    def contrast(self, contrast):
        self.write_cmd(_SET_CONTRAST)
        self.write_cmd(contrast)

    def invert(self, invert):
        self.write_cmd(_SET_NORM_INV | (invert & 1))

    def show(self, full_update = False):
        # self.* lookups in loops take significant time (~4fps).
        (w, p, db, rb) = (self.width, self.pages,
                          self.displaybuf, self.renderbuf)
        if self.rotate90:
            for i in range(self.bufsize):
                db[w * (i % p) + (i // p)] = rb[i]
        if full_update:
            pages_to_update = (1 << self.pages) - 1
        else:
            pages_to_update = self.pages_to_update
        #print("Updating pages: {:08b}".format(pages_to_update))
        for page in range(self.pages):
            if (pages_to_update & (1 << page)):
                self.write_cmd(_SET_PAGE_ADDRESS | page)
                self.write_cmd(_LOW_COLUMN_ADDRESS | 2)
                self.write_cmd(_HIGH_COLUMN_ADDRESS | 0)
                self.write_data(db[(w*page):(w*page+w)])
        self.pages_to_update = 0

    def pixel(self, x, y, color=None):
        if color is None:
            return super().pixel(x, y)
        else:
            super().pixel(x, y , color)
            page = y // 8
            self.pages_to_update |= 1 << page

    def text(self, text, x, y, color=1):
        super().text(text, x, y, color)
        self.register_updates(y, y+7)

    def line(self, x0, y0, x1, y1, color):
        super().line(x0, y0, x1, y1, color)
        self.register_updates(y0, y1)

    def hline(self, x, y, w, color):
        super().hline(x, y, w, color)
        self.register_updates(y)

    def vline(self, x, y, h, color):
        super().vline(x, y, h, color)
        self.register_updates(y, y+h-1)

    def fill(self, color):
        super().fill(color)
        self.pages_to_update = (1 << self.pages) - 1

    def blit(self, fbuf, x, y, key=-1, palette=None):
        super().blit(fbuf, x, y, key, palette)
        self.register_updates(y, y+self.height)

    def scroll(self, x, y):
        # my understanding is that scroll() does a full screen change
        super().scroll(x, y)
        self.pages_to_update =  (1 << self.pages) - 1

    def fill_rect(self, x, y, w, h, color):
        super().fill_rect(x, y, w, h, color)
        self.register_updates(y, y+h-1)

    def rect(self, x, y, w, h, color):
        super().rect(x, y, w, h, color)
        self.register_updates(y, y+h-1)

    def ellipse(self, x, y, xr, yr, color):
        super().ellipse(x, y, xr, yr, color)
        self.register_updates(y-yr, y+yr-1)

    def register_updates(self, y0, y1=None):
        # this function takes the top and optional bottom address of the changes made
        # and updates the pages_to_change list with any changed pages
        # that are not yet on the list
        start_page = max(0, y0 // 8)
        end_page = max(0, y1 // 8) if y1 is not None else start_page
        # rearrange start_page and end_page if coordinates were given from bottom to top
        if start_page > end_page:
            start_page, end_page = end_page, start_page
        for page in range(start_page, end_page+1):
            self.pages_to_update |= 1 << page

    def reset(self, res=None):
        if res is not None:
            res(1)
            time.sleep_ms(1)
            res(0)
            time.sleep_ms(20)
            res(1)
            time.sleep_ms(20)


class SH1106_I2C(SH1106):
    def __init__(self, width, height, i2c, res=None, addr=0x3c,
                 rotate=0, external_vcc=False, delay=0):
        self.i2c = i2c
        self.addr = addr
        self.res = res
        self.temp = bytearray(2)
        self.delay = delay
        if res is not None:
            res.init(res.OUT, value=1)
        super().__init__(width, height, external_vcc, rotate)

    def write_cmd(self, cmd):
        self.temp[0] = 0x80  # Co=1, D/C#=0
        self.temp[1] = cmd
        self.i2c.writeto(self.addr, self.temp)

    def write_data(self, buf):
        self.i2c.writeto(self.addr, b'\x40'+buf)

    def reset(self,res=None):
        super().reset(self.res)


class SH1106_SPI(SH1106):
    def __init__(self, width, height, spi, dc, res=None, cs=None,
                 rotate=0, external_vcc=False, delay=0):
        dc.init(dc.OUT, value=0)
        if res is not None:
            res.init(res.OUT, value=0)
        if cs is not None:
            cs.init(cs.OUT, value=1)
        self.spi = spi
        self.dc = dc
        self.res = res
        self.cs = cs
        self.delay = delay
        super().__init__(width, height, external_vcc, rotate)

    def write_cmd(self, cmd):
        if self.cs is not None:
            self.cs(1)
            self.dc(0)
            self.cs(0)
            self.spi.write(bytearray([cmd]))
            self.cs(1)
        else:
            self.dc(0)
            self.spi.write(bytearray([cmd]))

    def write_data(self, buf):
        if self.cs is not None:
            self.cs(1)
            self.dc(1)
            self.cs(0)
            self.spi.write(buf)
            self.cs(1)
        else:
            self.dc(1)
            self.spi.write(buf)

    def reset(self, res=None):
        super().reset(self.res)
        
from machine import Pin, I2C
i2c = I2C(scl=Pin(21), sda=Pin(20), freq=400000)
display = SH1106_I2C(128, 64, i2c, Pin(16), 0x3c)
display.sleep(False)
display.fill(0)
display.rotate(180)
display.text("Shatin is "+str(123)+"C", 0, 0)
display.show()

https://item.taobao.com/item.htm?_u=vbuhab0c8fc&id=692235616325&pisk=gfaLsUj6M1dLBGaKsWSMEFEN3lfGiGVU_JPXrYDHVReTeSd3x0DoV4e4H0TlY2m-yRMg-vVnRbi7E-ZndkDkyzeapeYoR8b-FSrNavc3-Qh7fJLuxWD3XQ3USkYoK9u8N-0RntbcoWPE846cnxid94gjO3OBEYg614c8jWtHGWPEzYOMFiq_TQhdgwAINY1t5bhIO4MINF1twb9IPviWChGjC4gSA0t_1jcXApMWA1KstbcWRXGS5hGSZHgSP8N16bksO4gS9i5KQBGpyo2QH1YJL2LWPPhKfiViCiyQJXhnnWapBddr9DHbOAB4G69Z2JnLSwpq9lNYiXePueuI2kwK14QJ72VYfJnTvTLtblN4PcENHnP4OowSKP6XyYq4JomqAILY68UtRAUPaUkQx7ao2y6XZvaUKPn4zpBiEoVgRcefIFer2kwK1qsPZr4xT7vmHbxC61Ky4DGw7oIF1mRpfIltn6iB43oo_fHc6tty4DGZ6xfB_3-rqf5..&spm=a1z09.2.0.0.20712e8dhZRCRN

#include <Arduino.h>

int freq = 2000;    // frequency
int channel = 0;    // aisle
int resolution = 8;   // Resolution

const int led = 4;
void setup()
{
  //Initialize GPIO, turn off tricolor light

  pinMode(4, OUTPUT);
  pinMode(17, OUTPUT);
  pinMode(16, OUTPUT);
  digitalWrite(4, 0);
  digitalWrite(16, 0);
  digitalWrite(17, 0);
  ledcAttach(channel, freq, resolution); // set channel
  //ledcAttachPin(led, channel);  // Connect the channel to the corresponding pin
}

void loop()
{
  digitalWrite(4, 0);
  digitalWrite(16, 1);
  digitalWrite(17, 1);
  delay(500);
  digitalWrite(4, 1);
  digitalWrite(16, 0);
  digitalWrite(17, 1);
  delay(500);
  digitalWrite(4, 1);
  digitalWrite(16, 1);
  digitalWrite(17, 0);
  delay(500);
  digitalWrite(4, 1);
  digitalWrite(16, 1);
  digitalWrite(17, 1);
  delay(500);
}

(Set to 115200, otherwise upload will fail)

諸葛亮勁係無資源嘅情況底下可以有高強嘅執行力。而香港人絕大部份都無執行力。

https://gitlab.quantr.hk/example/stm32/stm32f411ceu6-74hc595-shift-register

/* USER CODE BEGIN Header */
/**
 ******************************************************************************
 * @file           : main.c
 * @brief          : Main program body
 ******************************************************************************
 * @attention
 *
 * Copyright (c) 2025 STMicroelectronics.
 * All rights reserved.
 *
 * This software is licensed under terms that can be found in the LICENSE file
 * in the root directory of this software component.
 * If no LICENSE file comes with this software, it is provided AS-IS.
 *
 ******************************************************************************
 */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

/* USER CODE BEGIN PV */
void HC595_Send_Data(unsigned short data) {
	char i = 0;
	for (i = 0; i < 16; i++) {
		if (data & 0x1) {
			HAL_GPIO_WritePin(data_in_GPIO_Port, data_in_Pin, 1);
		} else {
			HAL_GPIO_WritePin(data_in_GPIO_Port, data_in_Pin, 0);
		}

		HAL_GPIO_WritePin(clock_in_GPIO_Port, clock_in_Pin, 0);
		HAL_Delay(5);
		HAL_GPIO_WritePin(clock_in_GPIO_Port, clock_in_Pin, 1);
		HAL_Delay(5);
		data >>= 1;
	}

	HAL_GPIO_WritePin(register_clock_in_GPIO_Port, register_clock_in_Pin, 0);
	HAL_Delay(5);
	HAL_GPIO_WritePin(register_clock_in_GPIO_Port, register_clock_in_Pin, 1);
	HAL_Delay(5);
}
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	unsigned short x = 0;
	while (1) {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
		HC595_Send_Data(x);

		x++;
		HAL_Delay(50);
	}
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  __HAL_RCC_PWR_CLK_ENABLE();
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief GPIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  /* USER CODE BEGIN MX_GPIO_Init_1 */

  /* USER CODE END MX_GPIO_Init_1 */

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(clock_in_GPIO_Port, clock_in_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOB, register_clock_in_Pin|data_in_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pin : clock_in_Pin */
  GPIO_InitStruct.Pin = clock_in_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(clock_in_GPIO_Port, &GPIO_InitStruct);

  /*Configure GPIO pins : register_clock_in_Pin data_in_Pin */
  GPIO_InitStruct.Pin = register_clock_in_Pin|data_in_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  /* USER CODE BEGIN MX_GPIO_Init_2 */

  /* USER CODE END MX_GPIO_Init_2 */
}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
	/* User can add his own implementation to report the HAL error return state */
	__disable_irq();
	while (1) {
	}
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

This is the tutorial to compile micropython with LVGL and burn it into the board

Steps:

git clone https://github.com/lvgl-micropython/lvgl_micropython.git
cd lvgl_micropython
python3 make.py esp32 clean \
  --flash-size=4 \
  --enable-jtag-repl=y \
  BOARD=ESP32_GENERIC_C6 \
  DISPLAY=st7789
esptool.py --baud 460800 write_flash 0 build/lvgl_micropy_ESP32_GENERIC_C6-4.bin

If success, you should see this

Open thonny and run

import lcd_bus
from micropython import const
import machine


# display settings
_WIDTH = const(172)
_HEIGHT = const(320)
_BL = const(22)
_RST = const(21)
_DC = const(15)

_MOSI = const(6)
_MISO = const(5)
_SCK = const(7)
_HOST = const(1)  # SPI2

_LCD_CS = const(14)
_LCD_FREQ = const(80000000)

_OFFSET_X = const(34)
_OFFSET_Y = const(0)

spi_bus = machine.SPI.Bus(
    host=_HOST,
    mosi=_MOSI,
    miso=_MISO,
    sck=_SCK
)

display_bus = lcd_bus.SPIBus(
    spi_bus=spi_bus,
    freq=_LCD_FREQ,
    dc=_DC,
    cs=_LCD_CS,
)

# we are going to let the display driver sort out the best freame buffer size and where to allocate it to.
# fb1 = display_bus.allocate_framebuffer(_BUFFER_SIZE, lcd_bus.MEMORY_INTERNAL | lcd_bus.MEMORY_DMA)
# fb2 = display_bus.allocate_framebuffer(_BUFFER_SIZE, lcd_bus.MEMORY_INTERNAL | lcd_bus.MEMORY_DMA)

import st7789  # NOQA
import lvgl as lv  # NOQA


display = st7789.ST7789(
    data_bus=display_bus,
    display_width=_WIDTH,
    display_height=_HEIGHT,
    backlight_pin=_BL,
    reset_pin=_RST,
    reset_state=st7789.STATE_LOW,
    backlight_on_state=st7789.STATE_PWM,
    color_space=lv.COLOR_FORMAT.RGB565,
    color_byte_order=st7789.BYTE_ORDER_RGB,
    rgb565_byte_swap=True,
    offset_x=_OFFSET_X,
    offset_y=_OFFSET_Y,
)

import task_handler  # NOQA

display.set_power(True)
display.init()
display.set_backlight(100)

th = task_handler.TaskHandler()

scrn = lv.screen_active()
scrn.set_style_bg_color(lv.color_hex(0x000000), 0)

label = lv.label(scrn)
label.set_text('HELLO WORLD!')
label.align(lv.ALIGN.CENTER, 0, 0)

Then you will see

Links you should read

https://www.waveshare.com/wiki/ESP32-C6-LCD-1.47

https://github.com/lvgl-micropython/lvgl_micropython

from machine import Pin
import neopixel
import time

pixels = neopixel.NeoPixel(Pin(8, Pin.OUT), 1)

while True:
	pixels[0] = (0xff, 0x00, 0x00)
	pixels.write()
	time.sleep(1)
	pixels[0] = (0x00, 0xff, 0x00)
	pixels.write()
	time.sleep(1)
	pixels[0] = (0x00, 0x00, 0xff)
	pixels.write()
	time.sleep(1)
	pixels[0] = (0xff, 0xff, 0x00)
	pixels.write()
	time.sleep(1)
	pixels[0] = (0x00, 0xff, 0xff)
	pixels.write()
	time.sleep(1)
	pixels[0] = (0xff, 0x00, 0xff)
	pixels.write()
	time.sleep(1)
	pixels[0] = (0xff, 0xff, 0xff)
	pixels.write()
	time.sleep(1)

from machine import UART
from time import sleep, sleep_ms, sleep_us
var1 = UART(1, baudrate=9600, tx=14, rx=15)
x=1
while True:
  var1.write(str(x))
  var1.write("\r\n")
  x+=1
  sleep_ms(250)

Mac command to read from UART

screen /dev/tty.usbmodem51850010041 9600

I don't understand why US gov list Hong Kong as their enemy

Download Unity international tutorial

password='something'
mysqldump -u root -p$password newblock.quantr.foundation|mysql -u root -p$password newblock.quantr.foundation`date +%Y%m%d`

If you are using macports instead of homebrew, you may have this problem. Solved by this: LDFLAGS="-L/opt/local/lib" CPPFLAGS="-I/opt/local/include" pyenv install 3.12.6

run this command

install_name_tool -add_rpath /Library/Developer/CommandLineTools/Library/Frameworks `which nextpnr-ice40`

Edit CMakeLists.txt, add these two line on top

INCLUDE_DIRECTORIES(/opt/local/include)
LINK_DIRECTORIES(/opt/local/lib)
import chisel3._
import chisel3.util._
import _root_.circt.stage.ChiselStage

class MyRam extends Module {
  val io = IO(new Bundle {
    val addr = Input(UInt(8.W))
    val dataIn = Input(UInt(8.W))
    val dataOut = Output(UInt(8.W))
    val write = Input(Bool())
  })

  val symcMem = SyncReadMem(256, UInt(8.W))
  val initDone = RegInit(false.B)

  when(!initDone) {
    io.dataOut := 0.U
    initDone := true.B
  }.otherwise {
    io.dataOut := DontCare // Ensure dataOut is not driven by default
    when(io.write) {
      symcMem.write(io.addr, io.dataIn)
    }.otherwise {
      io.dataOut := symcMem.read(io.addr)
    }
  }
}

object MyMain extends App {
  println(
    ChiselStage.emitSystemVerilog(
      gen = new MyRam,
      firtoolOpts = Array("-disable-all-randomization")
    )
  )
}
import chisel3._
import chisel3.util._
import _root_.circt.stage.ChiselStage

class MyRam extends Module {
  val io = IO(new Bundle {
    val addr = Input(UInt(8.W))
    val dataIn = Input(UInt(8.W))
    val dataOut = Output(UInt(8.W))
    val write = Input(Bool())
  })
  io.dataOut := DontCare

  val symcMem = SyncReadMem(256, UInt(8.W))
  when(io.write) {
    symcMem.write(io.addr, io.dataIn)
  }.otherwise {
    io.dataOut := symcMem.read(io.addr)
  }
}

object MyMain extends App {
  println(
    ChiselStage.emitSystemVerilog(
      gen = new MyRam,
      firtoolOpts = Array("-disable-all-randomization")
    )
  )
}

if you want to send one single byte

this is not working

writer.write(new Int32Array([0x4]).buffer);

this work

writer.write(new Uint8Array([0x4]));

There are two mode in micropython: REPL vs paste mode. I guess the uart of my ESP32 board has no flow control, so you can't send all bytes at once, because it is too fast, so I sleep 100 ms for every 100 bytes.

REPL mode

You can't just send your python code, you need to remind two things: the indent and the return of indent. See the below diagram, in line 26 should be one indent but you can't have it, because the line 25 is indent-ed so all next lines are supposed no need to indent again. So you can see from line 26 to 32, there is no indent. Secondly, in line 34, you need \r to return from indent to no-indent

Paste mode

In paste mode, you DON'T have to change anything to your code like the last section. But you need to send 0x5 to enter paste mode and send 0x4 to leave paste mode, after that, the program will run right after it. See line 61 and 72

香港有人係咁,廿幾歲畢業出黎做野,做左幾年對隻language開始熟,佢地唔係鑽落去language下面睇下發生緊乜野,例如啲code點compile呀,debug點做呀咁。佢地會作一出個難以解釋嘅現象,就係跳去另一隻high level language到再玩過,而當佢地玩到興起玩左幾年,佢地再次唔係想知道隻language嘅底層,而係再一次又跳去其它high level language到碌多一次,難道唔想知揸係手裏面把刀係咩黎?我叫呢一種現象做「香港Python仔現象」。舉個例子,2003年班友玩vc++,跟住跳去c#,跟住又跳去java,而家又跳去python。因為咁樣跳法本質上對過去學嘅語言都唔方認識得深,所以如果而家有個阿叔好推崇python,對其它language只停留係誇誇其談攞唔出到戰鬥力,佢大概率係咁。

要改變,就要做好科普,揭露python底層所有野,咁先至有機會改變。但呢班友會唔會變未知。

https://pavlokhmel.com/gitlab-docker-container-backup-and-restore.html

When running the chisel book example, we got Error compiling the sbt component 'compiler-bridge_2.12'. Here are the way to solve it

git clone https://github.com/schoeberl/chisel-examples.git

Edit hello-world/build.sbt

scalaVersion := "2.13.12"

scalacOptions ++= Seq(
  "-feature",
  "-language:reflectiveCalls",
)

// Chisel 3.5
// addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % "6.0.0" cross CrossVersion.full)
// libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "6.0.0"
// libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "0.6.0"

val chiselVersion = "6.0.0"
addCompilerPlugin("org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full)
libraryDependencies += "org.chipsalliance" %% "chisel" % chiselVersion
libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "0.6.0" % "test"

Edit hello-world/src/main/scala/Hello.scala

/*
 * This code is a minimal hardware described in Chisel.
 * 
 * Blinking LED: the FPGA version of Hello World
 */

import chisel3._
import circt.stage.ChiselStage

/**
 * The blinking LED component.
 */

class Hello extends Module {
  val io = IO(new Bundle {
    val led = Output(UInt(1.W))
  })
  val CNT_MAX = (50000000 / 2 - 1).U

  val cntReg = RegInit(0.U(32.W))
  val blkReg = RegInit(0.U(1.W))

  cntReg := cntReg + 1.U
  when(cntReg === CNT_MAX) {
    cntReg := 0.U
    blkReg := ~blkReg
  }
  io.led := blkReg
}

/**
 * An object extending App to generate the Verilog code.
 */
object Hello extends App {
  println(
    ChiselStage.emitSystemVerilog(
      new Hello(),
      firtoolOpts = Array("-disable-all-randomization", "-strip-debug-info")
    )
  )
}

香港人嘅老土活該沒有科技,我而家分析俾你地睇香港人嘅老土係有幾老土,以及老土嘅香港人點解覺得自己唔老土

第一老土 : 你憑咩

佢地所謂嘅論證不外乎係黎自你所受嘅教育同埋經驗,佢地會話你又唔係哈佛MIT學咩野人搞之類嘅言論,但呢班無讀歷史嘅人唔知好多科學家都係自學為主。(見下圖)

香港人老土在永遠人地努力做,佢地就會問"你憑咩",其實呢一句好無敵,因為當你做緊而又未做完嘅時間你的確無力反駁呢一句,由其是你係做緊一啲你自己都唔知做唔做到嘅野時,你更加無力反駁。但呢班友永遠唔明,科學嘅發現好多時就係意外發現,好多野唔做就唔唔知得唔得,而呢班咁嘅人最叻就係用呢句去質疑你,佢地嘅內心世界就係「嘩,你做呀,你有無諗過㗎」,跟住就會覺得自己好似好有經驗,好似真係以為自己曾經做過咁,知道你條路係唔通,其實個現實就係,呢班友根本無做過,而更深一層嘅就係,佢地連去嘗試嘅基本實力都無,佢地唔係連個for-loop都寫唔出就係技術只夠寫啲script仔,真係可憐。

第二老土 : 話人畫餅

呢個世界唔係所有人都需要理想,而理想呢樣野個實現率必定為低。香港地當然多人畫餅,但係係唔係畫餅好容易分,得個噏字唔做咪就係畫餅囉,會做嘅又點會算係畫餅呢,但係呢班咁嘅人就最叻攻擊啲為理想而行動嘅人。佢地個底其實係數佬,內心世界非常現實,我估計佢地後生嘅時候都曾經有理想,但手料跟唔上人到中年完全無哂動手能力,思想上變得越黎越現實,腦裏面諗一百個可能性去否定執行嘅成功率,不停俾借口自己逃避執行以至完全喪失執行力,佢地係編程上嘅實力只能點評人地寫嘅program,而自己乜都寫唔到。

Ada係連電都未係好識運用嘅年代就話要令機器有計算能力,如果香港班友返去佢嗰個時代,呢班友就會話人畫餅。嗰個時代根本就係非常簡陋。當呢班友話人畫餅,佢地嘅內心有一種好充盈嘅感覺,佢地會覺得:「嘿嘿,我真係叻,無俾你利用到」。但係個現實係咩呢,就係呢班友手料根本連俾人利用嘅資格都無,同你講下理想只係發下噏瘋而矣,唔好諗得自己咁有料可以俾人利用。

第三老土:話做唔做或者揾借口唔繼續做

話做唔做嘅人主要會話你唔夠條件做,做緊又揾借口唔繼續做嘅人會話發現你原來唔夠料做,又或者話發現你身上有啲缺點而唔再同你合作做。總之無論係咩原因都好,結果就係唔做。我地睇返Ada Lovelace個Case,當佢話要做一部Thinking machine嘅時候,佢mentor Charles Babbage唔會因為佢太天馬行空而屈佢畫餅,想反地會動手一齊做。而Charles Babbage亦都唔會話Ada無足夠嘅錢同埋未讀過大學就話人無料而做做下唔做。

https://conorfennell.github.io/scala-zen/articles/sbt.html

sbt "tasks -v"
  bgRun                           Start an application's default main class as a background job
  bgRunMain                       Start a provided main class as a background job
  clean                           Deletes files produced by the build, such as generated sources, compiled classes, and task caches.
  compile                         Compiles sources.
  console                         Starts the Scala interpreter with the project classes on the classpath.
  consoleProject                  Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports.
  consoleQuick                    Starts the Scala interpreter with the project dependencies on the classpath.
  copyResources                   Copies resources to the output directory.
  deliver                         Generates the Ivy file for publishing to a repository.
  deliverLocal                    Generates the Ivy file for publishing to the local repository.
  dependencyClasspath             The classpath consisting of internal and external, managed and unmanaged dependencies.
  dependencyClasspathAsJars       The classpath consisting of internal and external, managed and unmanaged dependencies, all as JARs.
  doc                             Generates API documentation.
  exportedProductJars             Build products that go on the exported classpath as JARs.
  exportedProductJarsIfMissing    Build products that go on the exported classpath as JARs if missing.
  exportedProductJarsNoTracking   Just the exported classpath as JARs without triggering the compilation.
  fullClasspath                   The exported classpath, consisting of build products and unmanaged and managed, internal and external dependencies.
  fullClasspathAsJars             The exported classpath, consisting of build products and unmanaged and managed, internal and external dependencies, all as JARs.
  internalDependencyAsJars        The internal (inter-project) classpath as JARs.
  javaOptions                     Options passed to a new JVM when forking.
  javacOptions                    Options for the Java compiler.
  mainClass                       Defines the main class for packaging or running.
  makePom                         Generates a pom for publishing when publishing Maven-style.
  manipulateBytecode              Manipulates generated bytecode
  mappings                        Defines the mappings from a file to a path, used by packaging, for example.
  package                         Produces the main artifact, such as a binary jar.  This is typically an alias for the task that actually does the packaging.
  packageBin                      Produces a main artifact, such as a binary jar.
  packageDoc                      Produces a documentation artifact, such as a jar containing API documentation.
  packageSrc                      Produces a source artifact, such as a jar containing sources and resources.
  printWarnings                   Shows warnings from compilation, including ones that weren't printed initially.
  publish                         Publishes artifacts to a repository.
  publishLocal                    Publishes artifacts to the local Ivy repository.
  publishM2                       Publishes artifacts to the local Maven repository.
  publishTo                       The resolver to publish to.
  publisher                       Provides the sbt interface to publisher
  run                             Runs a main class, passing along arguments provided on the command line.
  runMain                         Runs the main class selected by the first argument, passing the remaining arguments to the main method.
  scalacOptions                   Options for the Scala compiler.
  test                            Executes all tests.
  testOnly                        Executes the tests provided as arguments or all tests if no arguments are provided.
  testOptions                     Options for running tests.
  testQuick                       Executes the tests that either failed before, were not run or whose transitive dependencies changed, among those provided as arguments.
  unmanagedClasspath              Classpath entries (deep) that are manually managed.
  unmanagedJars                   Classpath entries for the current project (shallow) that are manually managed.
  unmanagedResources              Unmanaged resources, which are manually created.
  unmanagedSources                Unmanaged sources, which are manually created.
  update                          Resolves and optionally retrieves dependencies, producing a report.
  updateClassifiers               Resolves and optionally retrieves classified artifacts, such as javadocs and sources, for dependency definitions, transitively.
  updateSbtClassifiers            Resolves and optionally retrieves classifiers, such as javadocs and sources, for sbt, transitively.
  woo                             Woo

MX512G : 低压单通道有刷直流电机驱动器, RMB $2
MX1616S : 双路有刷直流马达驱动电路, RMB $7.8
TRSP5040A : SOP8語音OTP芯片40秒碩呈語音播報IC程序開發, RMB 0.27
RF2520A : 无线遥控收发器芯片, RMB $4.3

第一步其實好簡單,就係視覺角度唔好錯,畫細畫detail,畫太大舊野無意思

This tutorial give us a very good demo on rendering: https://www.youtube.com/watch?v=ukd1zO0Q-h4&t=317s

https://item.taobao.com/item.htm?_u=ibuhab0bb1b&id=628418040642&spm=a1z09.2.0.0.76e02e8dYbXP6k

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(100);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(100);                      // wait for a second
}

https://gitlab.com/peter-example/stm32/thei-stm32-demo-stm32f411ceu6

香港花太多時間係用玩具去吸引學生學編程,但無提升到對編程概念嘅表達,其實所有人都應該明白,如果係鐘意寫Program嘅小朋友,絕大部份第一次接觸就會愛上,其實係唔存在你要買好多玩具俾佢試先會所謂「啓發」到佢地嘅興趣。而個社會咁做不外乎得以下幾種可能

  1. 我係𡃁仔都不停叫阿媽買不同玩具玩啦,無接觸過編程嘅父母唔明白呢個道理所以不停買
  2. 因為賣玩具係一個賺錢嘅行業,而代理玩具黎香港賣亦都唔洗好有知識,自古以來香港係做左手交右手嘅生意,所以教育玩具業好發達。但真正對教育有研究嘅公司近乎無
  3. 老師要有舊見得到嘅野同校長交代,所以對接高編程技巧唔係首要,唔買舊玩具返黎又點有野睇呢,所以玩具業發達

上面三個原因互為影響互相加強,所以教育展變教育玩具展。

對香港嘅影響:

大家都係做代理唔研發,而大粒佬係呢啲展到都係得講野兩個字亦都唔會研發,最終後果就係香港洗好多錢係教育到最尾得個殼,香港人可以話俾外國人知香港投資左好多錢落教育,買左好多光鮮嘅玩具,除此之外乜都無。香港唔洗諗會出到Basic之父或者Logo之父等等一系列用實際行動去壓低學習難度嘅教育家,香港人唔洗諗,所以我地要以行動作出改變。

教育展中嘅清泉:

呢間公司做到好Deep,成套教學工具自己出,老細寫左本ROS嘅書有自己嘅學習思想,相信佢係用自己學習ROS嘅學習經驗濃縮出黎

This function is using SharePoint-Java-API library.


	public static HashSet<String> getAllFileOnSPO(Pair<String, String> token, String domain, String formDigestValue) throws UnsupportedEncodingException {
		int pageSize = 5000;
		int p_ID = 0;
		HashSet<String> filenames = new HashSet();
		int LastRow = 0;
		String NextHref = null;
		for (int z = 0; z < 1000; z++) {
			String data = "{ \n"
					+ "  \"parameters\": {\n"
					+ "    \"RenderOptions\": 2,\n"
					+ "    \"ViewXml\": \"<View>"
					+ "<Query>"
					+ "<OrderBy>"
					+ "<FieldRef Name=\\\"FileLeafRef\\\"/>"
					+ "</OrderBy>"
					+ "</Query>"
					+ "<ViewFields>"
					+ "   <FieldRef Name='LinkFilename'/>"
					+ "</ViewFields>"
					+ "<RowLimit Paged=\\\"TRUE\\\">" + pageSize + "</RowLimit>"
					+ "</View>\"\n"
					+ "    "
					+ "  }"
					+ "}";

//			System.out.println(data);
			JSONObject json2 = new JSONObject(data);
			String url;
			if (NextHref == null) {
				url = "/sites/DMS/_api/web/GetListUsingPath(DecodedUrl=%27%2Fsites%2FDMS%2FAccount%27)/RenderListDataAsStream?RootFolder=" + URLEncoder.encode("/sites/DMS/", "utf-8") + "&PageFirstRow=" + (z * pageSize) + "&p_ID=" + p_ID + "&Paged=TRUE&ix_Paged=TRUE&ix_ID=" + p_ID;
			} else {
				url = "/sites/DMS/_api/web/GetListUsingPath(DecodedUrl=%27%2Fsites%2FDMS%27)/RenderListDataAsStream" + NextHref;
			}
			System.out.println("url=" + url);
			String jsonString = SPOnline.post(token, domain, url, data, formDigestValue);
			json2 = new JSONObject(jsonString);

			System.out.println("length=" + json2.getJSONArray("Row").length());
			System.out.println("   RowLimit=" + json2.getInt("RowLimit"));
			System.out.println("   LastRow=" + json2.getInt("LastRow"));
			LastRow = json2.getInt("LastRow");

			JSONArray arr = json2.getJSONArray("Row");
			if (arr.length() == 0) {
				break;
			}
			for (int x = 0; x < arr.length(); x++) {
				JSONObject obj = arr.getJSONObject(x);
				filenames.add(obj.getString("FileLeafRef"));
			}
			p_ID = arr.getJSONObject(arr.length() - 1).getInt("ID");

			if (!json2.has("NextHref")) {
				break;
			}
			System.out.println("   NextHref=" + json2.getString("NextHref"));
			NextHref = json2.getString("NextHref");
		}
		return filenames;
	}
	

If your c# azure functions project in visual studio has error : "There is no Functions runtime available that matches the version specified in the project.". Do this :

Click : Download & Install