Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
arcadien committed Nov 21, 2023
1 parent 998db18 commit deffd74
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/Domain/Gun/Gun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ void Gun::setup(void) {
updateBatteryDisplayCycleCount = TICKS_BETWEEN_UI_UPDATE;

ui->displaySplash(2000);
ui->displayBatteryStatus(hal->getBatteryVoltageMv(),
hal->getBatteryVoltagePercent());

// mV is not used
ui->displayBatteryStatus(0, hal->getBatteryVoltagePercent());

ui->displayShootCount(0);
}
7 changes: 7 additions & 0 deletions lib/Domain/Gun/Gun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class Gun {

void toggleCalibrationMode() { calibrationMode = !calibrationMode; }

/**
* @brief Gun loop shall be called at least each 10ms,
* but interrupt shall trigger loop() execution in
* a shorter delay.
*
*/
void loop();

void setup();
};
1 change: 1 addition & 0 deletions lib/Domain/Gun/IGunUi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
class IGunUi {

public:
virtual void setup() = 0;
virtual void displaySplash(uint16_t timeoutMs) = 0;
virtual void displayBatteryStatus(uint16_t mv, uint8_t percent) = 0;
virtual void displayChargingStatus(bool isCharging) = 0;
Expand Down
3 changes: 2 additions & 1 deletion lib/Domain/Gun/SSD1306Ui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ static Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
*/
class SSD1306Ui : public IGunUi {
public:
SSD1306Ui() {
SSD1306Ui() {}

void setup() override{
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
for (;;)
; // Don't proceed, loop forever
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ lib_deps =
# -cdragon_isp
# -cavrispmkII

upload_command = avrdude -vv -b57600 -pm328p -c avrisp -Pcom11 $UPLOAD_FLAGS -U flash:w:$SOURCE:i
upload_command = avrdude -vv -b57600 -pm328p -c avrisp -Pcom9 $UPLOAD_FLAGS -U flash:w:$SOURCE:i

# upload_protocol=custom
# upload_speed=115200
Expand Down
3 changes: 2 additions & 1 deletion src/GunApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ void loop(void) {
}

void setup(void) {
hal.setupHeartbeat();
hal.setGun(&gun);
ui.setup();
gun.setup();
hal.setupHeartbeat();
}

0 comments on commit deffd74

Please sign in to comment.