update main

This commit is contained in:
zloihach 2023-06-27 00:56:28 +03:00
parent 7bd019cad9
commit ebc47a79ee
2 changed files with 10 additions and 1 deletions

2
demo.c
View File

@ -164,7 +164,7 @@ void checkButton(uint8_t pin, const char* message, void (*command)()) {
delay(200);
command();
}
// Обновляем состояние ШИМ, если что-то изменилось
if (pwm_changed) {
pwm_changed = 0;
pwm_check_state();

9
main.c
View File

@ -15,6 +15,7 @@ void setup() {
sendCommand(0x01, 0.0);
}
void loop() {
checkButton(0, "Turn on PWM!", enablePWM);
checkButton(1, "Turn off PWM!", disablePWM);
@ -22,6 +23,14 @@ void loop() {
checkButton(3, "Decrease frequency by 20%!", decreaseFrequency);
checkButton(4, "Increase duty cycle by 10%!", increaseDutyCycle);
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) {
pwm_changed = 0;