forked from ClemensElflein/CoverUI
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SA600/900 (RM-ECOW-V1.1.0) support (ClemensElflein#10)
* Add schematics * Original FW backup * LEDcontrol base- & sub-class separation for RM-ECOW-V100 * Nifty restructuration * Restructured Button code * Reimplemented magic buttons and finished button & LED restructuration * Split up Hardware Mods and added RM-ECOW-V1.0.0 * Evaluated Hall Support * Evaluated Hall Support * Fixed links * Started backport of C500- STM32 & GD32. Broken! * Finished backport of C500- STM & GD32 * Passed by reference instead value * Adapted Emergency for common C500 & RMECOWV100 usage * Add stock-firmware builds to CI * Add stock-firmware to CI job 'tagged-release' * Refactored again for SAxPRO backport. SAxPRO code isn't working yet! * Refactoring done. SAxPRO compiles. Added Hatch class * Fix HALL_MOD build * New binary location * Fix model typo * Finished SAxPRO and refactoring * Some final fixes * Fix packet * Fix out of bounds array access * Configure std LEDs as NC-LEDs * Final RL fixes * Fix docking states and backlight handling * Fix GD32F3x PLL * Activate boot anim, adjust charge min. value * Fix compile error * Some typo, version, link * Fix NX80i naming * OEM FW backup * RM-EC3-V1.1 schematics * Finish ST75256 controller driver * NX100i general done * Moved ST75256 to controller namespace * Change namespace * Change namespace * Change namespace * Made display a abstract Display class * Refactor display as abstract Display class * Fix missing subscription * Fix widget arrangement * Add emergencies STOP & HALL * Fix emergency, finish NX100i implementation * Final cosmetic changes * Adapt SAxPRO to new structure * Add NX100i to the docs * Minor corrections * CI build of NX100i FW * Actualized meaning of the LEDs for NX100i * Optimize UC1698 and flush_cb() * Remove "Next Language" info * Add circuit diagram * Fix once-only header identifier * Support SA650 RM-ECOW-V1.1.0 (9-Button/11-LED) CoverUI * Change magic button for SA650 * Change alive LED to be software driven (non hwtimer) * Add Buttons & LEDs for SA650 * Fix countdown anim * Fix emergency clear LED countdown * Add SA650 * Fix some links * Fix SA650 ToC link * Add SA650 * Add new SA650 CoverUI * Add new model info
- Loading branch information
1 parent
6e33024
commit 65433fa
Showing
155 changed files
with
39,442 additions
and
2,316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @file ButtonDebouncer.cpp | ||
* @author Apehaenger ([email protected]) | ||
* @brief YardForce CoverUI Button-Debouncer class for OpenMower https://github.com/ClemensElflein/OpenMower | ||
* Debouncing is done by continuos simple shifting the port states into an state array for later processing. | ||
* See Jack Ganssle debouncing http://www.ganssle.com/debouncing-pt2.htm | ||
* For code simplicity/speed, I debounce all pins, regardless if it has a button or not. Button separation has to be done by calling class. | ||
* @version 0.3 | ||
* @date 2023-10-26 | ||
* | ||
* @copyright Copyright (c) 2023 | ||
* | ||
*/ | ||
#include "include/ButtonDebouncer.hpp" | ||
|
||
void ButtonDebouncer::process_state(const uint32_t gpio_port_nr) // Has to get called regulary i.e. by timer (5ms) and store the (buttons) port state within states_ array | ||
{ | ||
#ifdef MCU_STM32 | ||
auto gpio_port = get_GPIO_Port(gpio_port_nr); | ||
states_[state_index_] = gpio_port->IDR ^ 0xFFFF; // XOR changes for pull-up states_ | ||
#else | ||
states_[state_index_] = GPIO_ISTAT(gpio_port[gpio_port_nr]) ^ 0xFFFF; // XOR changes for pull-up states_ | ||
#endif | ||
|
||
// Debounce | ||
uint16_t laststate_debounced_ = state_debounced_; | ||
unsigned int i; | ||
for (i = 0, state_debounced_ = 0xFFFF; i < NUM_BUTTON_STATES; i++) | ||
state_debounced_ &= states_[i]; | ||
|
||
// Circular buffer index | ||
state_index_++; | ||
if (state_index_ >= NUM_BUTTON_STATES) | ||
state_index_ = 0; | ||
|
||
// Save what changed | ||
state_changed_ = state_debounced_ ^ laststate_debounced_; | ||
}; | ||
|
||
/** | ||
* @brief Return boolean true if the given pin's button is pressed. | ||
* Take into notice that the returned state is already debounced. | ||
* | ||
* @param pin digital_pin | ||
* @return true if pressed, false if not pressed | ||
*/ | ||
bool ButtonDebouncer::is_pressed(uint8_t pin) | ||
{ | ||
return state_debounced_ & digitalPinToBitMask(pin); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/** | ||
* @file Buttons.cpp | ||
* @author Apehaenger ([email protected]) | ||
* @brief YardForce CoverUI Buttons class for OpenMower https://github.com/ClemensElflein/OpenMower | ||
* @version 0.6 | ||
* @date 2023-11-05 | ||
* | ||
* @copyright Copyright (c) 2023 | ||
* | ||
*/ | ||
#include <Arduino.h> | ||
#include <stdint.h> | ||
#include <map> | ||
#include "include/Buttons.hpp" | ||
#include "../BttnCtl.h" | ||
|
||
#ifdef MCU_STM32 | ||
#define DIGITAL_PIN_TO_PORT_NR(p) (STM_PORT(digitalPinToPinName(p))) | ||
#else // MCU_GD32 | ||
#define DIGITAL_PIN_TO_PORT_NR(p) (GD_PORT_GET(DIGITAL_TO_PINNAME(p))) | ||
#endif | ||
|
||
extern void sendMessage(void *message, size_t size); | ||
|
||
/** | ||
* @brief Setup GPIOs | ||
* | ||
*/ | ||
void Buttons::setup() | ||
{ | ||
for (auto const &it : kBtnDefByNumMap) // Loop over Button-Num -> button pin map | ||
{ | ||
// Create debouncer if not already exists for this Pin's GPIO_Port_Nr | ||
uint32_t gpio_port_nr = DIGITAL_PIN_TO_PORT_NR(it.second.pin); | ||
auto debouncer = debouncer_by_gpio_port_nr_map.find(gpio_port_nr); | ||
if (debouncer == debouncer_by_gpio_port_nr_map.end()) | ||
debouncer_by_gpio_port_nr_map.insert(std::pair<uint32_t, ButtonDebouncer>(gpio_port_nr, ButtonDebouncer())); | ||
|
||
pinMode(it.second.pin, INPUT_PULLUP); | ||
} | ||
}; | ||
|
||
/** | ||
* @brief Process GPIO states by debouncer. Has to get called regulary i.e. by timer (5ms) | ||
* | ||
*/ | ||
void Buttons::process_states() | ||
{ | ||
for (std::map<uint32_t, ButtonDebouncer>::iterator it = debouncer_by_gpio_port_nr_map.begin(); it != debouncer_by_gpio_port_nr_map.end(); ++it) | ||
it->second.process_state(it->first); | ||
}; | ||
|
||
/** | ||
* @brief Get corresponding LED num for button num | ||
* | ||
* @param button_nr | ||
* @return uint8_t LED num. -1 of not exists. | ||
*/ | ||
int8_t Buttons::get_led(uint8_t button_nr) | ||
{ | ||
auto btn_def_it = kBtnDefByNumMap.find(button_nr); // Find button_nr and get iterator pair | ||
if (btn_def_it != kBtnDefByNumMap.end()) | ||
return btn_def_it->second.led_num; | ||
|
||
return -1; | ||
} | ||
|
||
/** | ||
* @brief Return boolean true if the given button number is pressed. | ||
* Take into notice that the returned state is already debounced. | ||
* | ||
* @param uint8_t button_nr | ||
* @return true if pressed, false if not pressed | ||
*/ | ||
bool Buttons::is_pressed(uint8_t button_nr) | ||
{ | ||
auto btn_def_it = kBtnDefByNumMap.find(button_nr); // Find button_nr and get iterator pair | ||
if (btn_def_it != kBtnDefByNumMap.end()) | ||
{ | ||
uint32_t gpio_port_nr = DIGITAL_PIN_TO_PORT_NR(btn_def_it->second.pin); | ||
auto debouncer_it = debouncer_by_gpio_port_nr_map.find(gpio_port_nr); // Find debouncer and get iterator pair | ||
if (debouncer_it != debouncer_by_gpio_port_nr_map.end()) | ||
{ | ||
return debouncer_it->second.is_pressed(btn_def_it->second.pin); | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
/** | ||
* @brief Return ButtonNum of the first detected pressed button. | ||
* Take into notice that the returned state is already debounced. | ||
* | ||
* @return uint8_t 0 = none pressed, >0 = ButtonNum | ||
*/ | ||
uint8_t Buttons::is_pressed() | ||
{ | ||
for (auto const &it : kBtnDefByNumMap) // Loop over Button-Num -> button pin map | ||
if (is_pressed(it.first)) | ||
return it.first; | ||
|
||
return 0; | ||
}; | ||
|
||
/** | ||
* @brief Send 'rain' message via COBS with last read rain-sensor- value (together with (currently static) threshold) | ||
* | ||
*/ | ||
void Buttons::send(uint16_t button_id, uint8_t press_duration) | ||
{ | ||
msg_event_button msg = { | ||
.type = Get_Button, | ||
.button_id = button_id, | ||
.press_duration = press_duration}; | ||
sendMessage(&msg, sizeof(msg)); | ||
} |
Oops, something went wrong.