use sparkfun lib for sensors adafruit has issues
This commit is contained in:
31
buttons.cpp
31
buttons.cpp
@@ -6,16 +6,45 @@ uint8_t g_previous_mode_button_state = 1;
|
||||
uint32_t g_last_debounce_time = 0;
|
||||
uint32_t g_debounce_delay = 50;
|
||||
|
||||
Button buttonCenter(BUTTON_CENTER);
|
||||
Button buttonLeft(BUTTON_LEFT);
|
||||
Button buttonRight(BUTTON_RIGHT);
|
||||
|
||||
void initButtons(void)
|
||||
{
|
||||
Serial.print("initButtons:");
|
||||
buttonCenter.begin();
|
||||
buttonLeft.begin();
|
||||
buttonRight.begin();
|
||||
|
||||
pinMode(MODE_BUTTON_PIN, INPUT_PULLUP); // Pin for switching screens button
|
||||
Serial.println(" OK");
|
||||
}
|
||||
|
||||
void handleButtons(void)
|
||||
{
|
||||
g_previous_mode_button_state = g_current_mode_button_state;
|
||||
//handle buttons
|
||||
buttonCenter.read();
|
||||
buttonLeft.read();
|
||||
buttonRight.read();
|
||||
|
||||
if (buttonCenter.wasPressed())
|
||||
{
|
||||
backlightRefresh();
|
||||
}
|
||||
|
||||
if (buttonLeft.wasPressed())
|
||||
{
|
||||
previousSensor();
|
||||
backlightRefresh();
|
||||
}
|
||||
|
||||
if (buttonRight.wasPressed())
|
||||
{
|
||||
nextSensor();
|
||||
backlightRefresh();
|
||||
}
|
||||
|
||||
g_current_mode_button_state = digitalRead(MODE_BUTTON_PIN);
|
||||
|
||||
// Check if button is now pressed and it was previously unpressed
|
||||
|
||||
Reference in New Issue
Block a user