update main
This commit is contained in:
parent
7bd019cad9
commit
ebc47a79ee
2
demo.c
2
demo.c
@ -164,7 +164,7 @@ void checkButton(uint8_t pin, const char* message, void (*command)()) {
|
|||||||
delay(200);
|
delay(200);
|
||||||
command();
|
command();
|
||||||
}
|
}
|
||||||
// Обновляем состояние ШИМ, если что-то изменилось
|
|
||||||
if (pwm_changed) {
|
if (pwm_changed) {
|
||||||
pwm_changed = 0;
|
pwm_changed = 0;
|
||||||
pwm_check_state();
|
pwm_check_state();
|
||||||
|
9
main.c
9
main.c
@ -15,6 +15,7 @@ void setup() {
|
|||||||
sendCommand(0x01, 0.0);
|
sendCommand(0x01, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
checkButton(0, "Turn on PWM!", enablePWM);
|
checkButton(0, "Turn on PWM!", enablePWM);
|
||||||
checkButton(1, "Turn off PWM!", disablePWM);
|
checkButton(1, "Turn off PWM!", disablePWM);
|
||||||
@ -22,6 +23,14 @@ void loop() {
|
|||||||
checkButton(3, "Decrease frequency by 20%!", decreaseFrequency);
|
checkButton(3, "Decrease frequency by 20%!", decreaseFrequency);
|
||||||
checkButton(4, "Increase duty cycle by 10%!", increaseDutyCycle);
|
checkButton(4, "Increase duty cycle by 10%!", increaseDutyCycle);
|
||||||
checkButton(5, "Decrease duty cycle by 10%!", decreaseDutyCycle);
|
checkButton(5, "Decrease duty cycle by 10%!", decreaseDutyCycle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkButton(uint8_t pin, const char* message, void (*command)()) {
|
||||||
|
if (bit_is_clear(PINC, pin)) {
|
||||||
|
Serial.println(message);
|
||||||
|
delay(200);
|
||||||
|
command();
|
||||||
|
}
|
||||||
|
|
||||||
if (pwm_changed) {
|
if (pwm_changed) {
|
||||||
pwm_changed = 0;
|
pwm_changed = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user