You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

iocontrol_serialout

  • behavior:
    • minimal program
    • start handler immediately, and print out a message at regular interval showing current time in ms
  • pre-requisite:
    • none
  • concepts:
    • IO_Control
      • begin
      • execute
      • enableScheduler
      • isSchedulerTimeEvent(_status)
    • use "DeclareHandlerBegin" and "DeclareHandlerEnd" for declare a handler function
    • enable scheduler with handler function for repeated execution
    • handler cannot start at t=0 (usually t=86 due to setup and other overhead)

iocontrol_serialout_fsm1

  • behavior:
    • modified from iocontrol_serialout
    • implement a FSM (finite state machine) to control sequential printing of messages
  • pre-requisite:
    • iocontrol_serialout
  • concepts:
    • add a variable for state, count from 0 to 2 and goes back to 0 again
    • use switch statement
    • effect of "interval" on duration for each state
    • prepare for complex case of finite state machine

iocontrol_serialout_fsm2

  • behavior:
    • repeat the print sequence in iocontrol_serialout_fsm1 for a number of times
  • pre-requisite:
    • iocontrol_serialout_fsm1
  • concepts:
    • extended from iocontrol_serialout
    • add another variable to control repeat count

iocontrol_serialin

  • behavior:
    • read in characters from Serial monitor and display in the handler
  • pre-requisite:
    • iocontrol_serialout
  • concepts:
    • Serial
      • available
      • readStringUntil
    • String and its functions
    • if ... else ...
    • boolean expression

binout_timedwrite

  • behavior:
    • turn on GPIO 12 at 1000ms and turn off at 2000ms
  • pre-requisite:
    • iocontrol_serialout
  • concepts:
    • BinOutControl
      • init
      • enableScheduler
      • read
      • write
    • PinMgr
      • request
    • basic steps to allocate resource for a pin
    • handler for BinOutControl
      • write HIGH after onTimeMS, and LOW after offTimeMS

binout_serialin_timedwrite

  • behavior:
    • parse input from Serial Monitor to control when to turn on LED at GPIO12 and duration
    • two formats:
      • <duration>
      • <relative start time>,<duration>
    • with checking of input message from Serial Monitor
      • reject if comma at start, or more than one comma
    • <duration> = 1000 may not have any observable change due to turn around time of serial communication being too long
  • pre-requisite:
    • binout_timedwrite
    • iocontrol_serialin
  • concepts:
    • String
      • indexOf
      • substring
      • toInt

binout_play_oneseq

  •  behavior:
    • playback a sequence on IO12 using GPIO output, at t=2000ms after reset, for 2 times
  • pre-requisite:
    • binout_timedwrite
  • concepts:
    • BinOutControl
      • playRelTime
      • isXXX(_status) - relating to sequence
    •  BinOutSequence
      • addSetState( duration, state)
  •  extension
    • play sequence for one time and two times to illustrate difference between "OneSeqEnded" and "AllSeqEnded"

binout_play_altseq

  • behavior:
    • playback two sequences alternatively on IO12, using GPIO output
  • pre-requisite:
    • binout_play_oneseq
    • iocontrol_serialout_fsm1
    • iocontrol_serialout_fsm2
  • concepts:
    • BinOutControl.playRelTime in handler
    • use finite state machine concept
    • use "isAllSeqEnded()"

binout_serialin_playseq_immed

  • behavior:
    • play sequence immediately according to input from Serial monitor
    • two inputs:
      • 0 - start playing sequence 0 immediately
      • 1 - start playing sequence 1 immediately
  • pre-requisite:
    • binout_play_oneseq
    • binout_play_altseq
  • concepts
    • BinOutControl.playRelTime invoke in handler
    • String::equals

binout_serialin_playseq_follow

  • behavior:
    • play sequence AFTER current sequence finished playback, according to input from Serial monitor
    • modified from binout_serialin_playseq_immed
  • pre-requisite:
    • binout_serialin_playseq_immed
  • concepts:
    • BinOutControl.isPlaying
    • BinOutControl.isAllSeqEnded
    • add "nextSeqIndex" to remember which sequence to play next

binin_changetime

  •  behavior:
    • detect change of BOOT button (IO09) and report time of change and state AFTER change
  • pre-requisite
    • iocontrol_serialout
  • concepts:
    • BinInControl
      • init - pin and input mode
      • enableScheduler
      • enableInterrupt - RISING, FALLING, CHANGE, HIGH, LOW
      • isBinInTriggered
      • getInterruptTime
      • getInterruptState

adc_read

  • circuit:
  • behavior:
    • joystick analog outputs connect to IO00 and IO01 respectively
    • read analog outputs every 100ms and outputs on Serial Monitor
  • pre-requisite:
    • iocontrol_serialout
  • concepts
    • ADCControl
      • init - adc_index (must be 1), pin index (must be 0 to 4)
      • read
      • getMaxValue

adc_thres

  • circuit:
  • behavior:
    • set threshold for three regions, and report an ID for region (0,1, or 2) of each analog input on Serial Monitor when ID changed
  • pre-requisite:
    • adc_read
  • concepts
    • ADCControl
      • enableScheduler and handler
      • setThreshold
      • isIndexChanged
      • getLastIndex
      • getLastChangeTime
      • getLastValue
    • getLastXXX only valid when isIndexChanged is true
    • vector and initialization
      • std::vector - search for "std::vector" online for documentation
      • template
      • push_back

adc_binin_joystick

  • circuit:
  • behavior:
    • handlers for detecting ADC at IO00 and IO01, and threshold in three ranges
    • when button is pushed or released, change time is determined and current state of ADC0 and ADC1 are printed
  • pre-requisite:
    • adc_thres
    • binin_changetime
  • concepts:
    • INPUT_PULLUP for IO05, so that no external pull-up resistor is required

pwm_setduty

  • behavior:
    • use PWM output on IO12 to change brightness from fully-off to fully-on
    • interval = 50ms, each interval increment duty by 100
  • pre-requisite:
    • iocontrol_serialout
  • concepts:
    • PWMControl
      • init
      • getFreq
      • setDuty(duty)
    • maximum 6 PWM channels, map to any GPIO output
    • all with same frequency, but can have different duty

pwm_play_oneseq

  • behavior:
    • play back a PWM sequence for two times
  • pre-requisite:
    • pwm_setduty

    • binout_play_oneseq
  •  concepts:
    • PWMSequence
      • addSetDuty
      • addFade
    • PWMControl
      • playRelTime

servo_setAngle

servo_play_oneseq

  • circuit:
    • use SG90 servo motor
    • connections:
      • SG90ESP32C3
        PWMIO08
        VCC5V
        GNDGND
  • behavior:
    • play back one servo motor sequence for once
    • smooth movement when interval is smaller (50ms vs 20ms)
  • pre-requisite:
    • servo_setAngle

    • binout_play_oneseq
  • concepts:
    • ServoSequence
      • addSetAngle
      • addMoveFromToAngle
    • has to pass ServoControl object for checking 
      • maximum angular speed = 60deg/0.1s
      • angle limits = from 0 to 180 degrees
    • angle should NOT be too close to the extreme limit; prefer to use the range 20 to 160 instead to avoid damaging servo motor

tone_setTone

  • circuit:
    • use piezo speaker
    • connections:
      • piezo speakerESP32C3
        +veIO13
        GNDGND
  • behavior:
    • play a frequency and a note, each for 250ms
  • pre-requisite
    • iocontrol_serialout_fsm1
    • iocontrol_serialout_fsm2
  • concepts
    • ToneControl
      • init
      • setTone
      • setNote ( notebase, octave, duty)
        • NoteBaseType refer to ToneControl.h
        • octave - from 0 to 8
      • getMaxDuty
    • setTone
      • freq ==0 means silent

tone_play_oneseq

  • circuit:
    • use piezo speaker
    • connections:
      • piezo speakerESP32C3
        +veIO13
        GNDGND
  • behavior:
    • play a tone sequence for once
  • pre-requisite
    • tone_setTone
    • binout_play_oneseq
  • concepts:
    • ToneSequence
      • addSetTone
      • addSetNote
      • addInterpolateTone

mpr121_touchrelease_event

  • circuit:
  • behavior:
    • initialize MPR121 module and report touch and release event at each terminal and time of detection
  • pre-requisite
    • binin_changetime
  • concepts
    • MPR121Control
      • isTouchReleaseEvent
      • touchedTimeMS[]
      • releasedTimeMS[]
    • for loop
    • access of element in vector/array (not std::vector)

addrled_setColor

addrled_play_seqs

  • circuit:
    • WS2812 strip with at least 4 LEDs
    • connections
      • WS2812ESP32C3
        DINIO19
        +5V5V
        GNDGND
  • behavior:
    • defined three sequences
    • expect 4 LEDs, and divided into three groups, each group play one sequence
    • for one group, sequence is continued playing after ending the sequence
  • pre-requisite:
    • binout_play_altseq
    • binout_play_altseq
  • concepts:
    • AddrLEDControl
      • playRelTime
    • AddrLEDSequence
      • addSetRGB
      • addSetHSV
      • addSetInterpolateRGB
      • addSetInterpolateHSV

addrLED_seq_pause_resume

  • circuit:
    • WS2812 strip with at least 2 LEDs
    • connections
      • WS2812ESP32C3
        DINIO19
        +5V5V
        GNDGND
  • behavior:
    • define two sequences and play back each sequence to each group, with one LED per group
    • one sequence paused after playing 2nd command, and then resume after the other sequence completed playing
  • pre-requisite:
    • addrled_play_seqs
  • concepts:
    • AddrLEDControl::pauseBeforeNextCommand()
    • AddrLEDControl::isOneSeqPaused()
    • AddrLEDControl::resume()

oled_display_time

  • circuit:
    • use SH1106 or SSD1306 OLED display
    • connections
      • SH1106 or SSD1306 displayESP32C3
        VCC3.3v
        GNDGND
        SCLIO10
        SDAIO06
  • behavior:
    • initialize SH1106 display and display current time in HH:MM:SS format
    • time since reset
  • pre-requisite:
    • binout_timedwrite
  • concepts:

oled_display_ntptime

  • circuit:
    • use SH1106 or SSD1306 OLED display
    • connections
      • SH1106 or SSD1306 displayESP32C3
        VCC3.3v
        GNDGND
        SCLIO10
        SDAIO06
  • behavior:
    • connect to the SSID with password in the source code, and connect to the NTP server
    • initialize SH1106 display and display current time in HH:MM:SS format
    • If failed to connect to SSID, time since reset will be used instead of the local time
  • pre-requisite:
    • oled_display_time
  • concepts:
    • connect to SSID using WiFiControl

oled_display_bitmap

mp3_dfplayer

  • No labels