|
發表於 2018-9-27 17:23:10
|
顯示全部樓層
- #include<arduino.h>
- #include "PT6961.h"
- #include "Pushbutton.h"
- #define OUTPUT_CONTROL 0
- #define BUTTON 7
- #define KEY_UP 6
- #define KEY_DOWN 5
- #define PT6961_CS 10
- #define PT6961_CLK 9
- #define PT6961_DIN 8
- #define DELAY_TIME 100 // 100ms
- #define SPOT_TIME_MAX 9990
- #define SPOT_TIME_MIN 10
- #define TRIGGER_AUTOSPOT_TIME 1000 // 1s
- Pushbutton button_enter(BUTTON);
- Pushbutton button_up(KEY_UP);
- Pushbutton button_down(KEY_DOWN);
- PT6961 LED(PT6961_DIN, PT6961_CLK, PT6961_CS);
- uint16_t hold_time = DELAY_TIME;
- uint16_t hold_time_x = DELAY_TIME+10;
- void setup()
- {
- pinMode(OUTPUT_CONTROL,OUTPUT);
- LED.initDisplay();
- }
- void loop()
- {
- while(1)
- {
- int count;
- int autospot_hold;
- if(hold_time_x != hold_time) {
- hold_time_x = hold_time;
- LED.sendNum(hold_time_x,0);
- }
- while(!button_enter.isPressed()) // check key up/down if no enter key pressed.
- {
- // process key up pressed
- while(button_up.isPressed() && hold_time < SPOT_TIME_MAX)
- {
- hold_time+=10;
- LED.sendNum(hold_time,0);
- delay(150); // simple debonce
- if(!button_up.isPressed()) break;
- }
- // process key down pressed
- while(button_down.isPressed() && hold_time > SPOT_TIME_MIN)
- {
- hold_time-=10;
- LED.sendNum(hold_time,0);
- delay(150);
- if(!button_down.isPressed()) break;
- }
- }
-
- autospot_hold=0;
- while(button_enter.isPressed() && autospot_hold < TRIGGER_AUTOSPOT_TIME) { // hold 1 sec for trigger auto spot.
- delay(100);
- autospot_hold+=100;
- }
- if(!button_enter.isPressed() || autospot_hold < TRIGGER_AUTOSPOT_TIME) continue;
- // trun on
- digitalWrite(OUTPUT_CONTROL,HIGH);
- delay(hold_time);
- digitalWrite(OUTPUT_CONTROL,LOW);
-
- button_enter.waitForRelease();
- delay(150);
- }
- }
複製代碼
100ms_demo_V2.zip
(13.91 KB, 下載次數: 6)
|
評分
-
6
查看全部評分
-
|