From cd0c056d717045cfd99aa497fc76148bfbb5c9ba Mon Sep 17 00:00:00 2001 From: Clemens Nowitzki Date: Mon, 15 Sep 2025 18:14:46 +0200 Subject: [PATCH 1/4] Update OBSPro code to new hardware revision --- src/OpenBikeSensorFirmware.cpp | 72 ---------------------------------- src/displays.h | 14 ++----- src/gps.cpp | 17 +++++--- src/utils/button.cpp | 4 -- src/variant.h | 11 +----- src/writer.cpp | 2 +- 6 files changed, 18 insertions(+), 102 deletions(-) diff --git a/src/OpenBikeSensorFirmware.cpp b/src/OpenBikeSensorFirmware.cpp index 052ff2fa..b6440a5f 100644 --- a/src/OpenBikeSensorFirmware.cpp +++ b/src/OpenBikeSensorFirmware.cpp @@ -229,70 +229,6 @@ static void buttonBluetooth(const DataSet *dataSet, uint16_t measureIndex) { static uint8_t shutdownState = 0; -#ifdef OBSPRO -// Power-management keep alive timer -// This function is called every 100 ms -static unsigned long timeOfLastPowerKeepAlive = 0; -static uint8_t buttonPressedCounter = 0; -static void powerKeepAliveTimerISR() -{ - // Send "keep alive" trigger to power management module - // This is done by toggling the pin every 300 ms or more - if(shutdownState == 0) - { - if(!digitalRead(IP5306_BUTTON) && millis() - timeOfLastPowerKeepAlive > POWER_KEEP_ALIVE_INTERVAL_MS) - { - timeOfLastPowerKeepAlive = millis(); - digitalWrite(IP5306_BUTTON, HIGH); - } - else if(digitalRead(IP5306_BUTTON) && millis() - timeOfLastPowerKeepAlive > 300) - { - timeOfLastPowerKeepAlive = millis(); - digitalWrite(IP5306_BUTTON, LOW); - } - } - - // Soft power-off OBSPro when button is pressed for more than 2 seconds - if(button.read()) - { - if(buttonPressedCounter < 255) - buttonPressedCounter++; - } - else - buttonPressedCounter = 0; - - if(shutdownState == 0 && buttonPressedCounter >= 50) { - shutdownState = 1; - } - switch(shutdownState) - { - case 1: - digitalWrite(IP5306_BUTTON, LOW); - break; - case 4: - digitalWrite(IP5306_BUTTON, HIGH); - break; - case 7: - digitalWrite(IP5306_BUTTON, LOW); - break; - case 10: - digitalWrite(IP5306_BUTTON, HIGH); - break; - case 13: - digitalWrite(IP5306_BUTTON, LOW); - noInterrupts(); - while(1) - NOP(); - break; - default: - break; - } - if(shutdownState != 0 && shutdownState < 13) - shutdownState++; -} - -#endif - void setup() { Serial.begin(115200); log_i("openbikesensor.org - OBS/%s", OBSVersion); @@ -310,14 +246,6 @@ void setup() { digitalWrite(GPS_POWER_PIN,HIGH); #endif -#ifdef OBSPRO - // Setup power management timer to trigger every 100ms (clock is 80 MHz) - timer0_powermanagement_cfg = timerBegin(0, 1000, true); - timerAttachInterrupt(timer0_powermanagement_cfg, &powerKeepAliveTimerISR, true); - timerAlarmWrite(timer0_powermanagement_cfg, 8000, true); - timerAlarmEnable(timer0_powermanagement_cfg); -#endif - //############################################################## // Setup display //############################################################## diff --git a/src/displays.h b/src/displays.h index 44af3885..e309634e 100644 --- a/src/displays.h +++ b/src/displays.h @@ -61,22 +61,16 @@ class DisplayDevice { private: void handleHighlight(); void displaySimple(uint16_t value); -#ifdef OBSPRO - U8G2* m_display = new U8G2_ST7567_JLX12864_F_4W_HW_SPI(U8G2_R0, LCD_CS_PIN, LCD_DC_PIN, LCD_RESET_PIN); // SPI based JHD12864-G156BT for OBSPro -#endif -#ifdef OBSCLASSIC + U8G2* m_display = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE); // original OBSClassic display -#endif + String gridText[ 4 ][ 6 ]; uint8_t mLastProgress = 255; uint8_t mCurrentLine = 0; bool mInverted = false; -#ifdef OBSPRO - bool mFlipped = false; -#endif -#ifdef OBSCLASSIC + bool mFlipped = true; -#endif + uint32_t mHighlightTill = 0; bool mHighlighted = false; diff --git a/src/gps.cpp b/src/gps.cpp index a3640592..79a6b2f4 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -72,6 +72,7 @@ void Gps::begin() { configureGpsModule(); } pollStatistics(); +#ifndef UBX_M10 if((!is_neo6()) || (!SD.exists(AID_INI_DATA_FILE_NAME))) { // we're on a non-6 neo and avoid AID_INI because is deprecated // or we're on a neo6 but last boot we didn't get far enough to receive fresh @@ -81,13 +82,14 @@ void Gps::begin() { if (!is_neo6()) log_i("Coldstart because we found that newer neos profit from that."); coldStartGps(); - } + } pollStatistics(); +#endif if (is_neo6()) { enableAlpIfDataIsAvailable(); } - + if (mLastTimeTimeSet == 0) { #ifdef UBX_M10 setMessageInterval(UBX_CFG_KEY_ID::CFG_MSGOUT_UBX_NAV_TIMEGPS_UART1, 1); @@ -107,6 +109,7 @@ void Gps::begin() { //Serial.updateBaudRate(9600); //mSerial.begin(9600, SERIAL_8N1); // Debug - forward gps serial to normal serial + /* log_e("--------_STARTING LOOP"); while(1) @@ -117,7 +120,8 @@ void Gps::begin() { val = Serial.read(); if(val >= 0) mSerial.write(val); - }*/ + } + */ } void Gps::sendUbx(UBX_MSG ubxMsgId, const uint8_t payload[], uint16_t length) { @@ -271,7 +275,7 @@ void Gps::configureGpsModule() { bool success = sendAndWaitForAck(UBX_MSG::CFG_GNSS, UBX_CFG_GNSS, sizeof(UBX_CFG_GNSS)); if (success) { addStatisticsMessage("Successfully set GNSS"); - } + } else { addStatisticsMessage("GNSS not configured, likely older GPS"); } @@ -355,7 +359,7 @@ void Gps::softResetGps() { void Gps::coldStartGps() { log_i("Cold-Start GPS!"); handle(); - const uint8_t UBX_CFG_RST[] = {0xFF, 0xFF, 0x00, 0x00}; + const uint8_t UBX_CFG_RST[] = {0xFF, 0xFF, 0x00, 0x00}; // we had the case where the reset took several seconds // see https://github.com/openbikesensor/OpenBikeSensorFirmware/issues/309 // Newer firmware (like M10 and likely also M8) will not ack this @@ -576,7 +580,8 @@ bool Gps::sendAndWaitForAck(UBX_MSG ubxMsgId, const uint8_t *buffer, size_t size log_w("Retry to send 0x%04x after %dms.", ubxMsgId, millis() - loopStart); } if (result) { - log_d("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start); + //log_d("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start); + log_e("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start); } else { log_e("Failed to send. 0x%04x NAK: %d after %dms", ubxMsgId, mNakReceived, millis() - start); } diff --git a/src/utils/button.cpp b/src/utils/button.cpp index 224e1db7..150e8ded 100644 --- a/src/utils/button.cpp +++ b/src/utils/button.cpp @@ -65,11 +65,7 @@ bool Button::gotPressed() { int Button::read() const { // not debounced -#ifdef OBSPRO - return !digitalRead(mPin); -#else return digitalRead(mPin); -#endif } int Button::getState() const { diff --git a/src/variant.h b/src/variant.h index 7ee270ca..1e5379f2 100644 --- a/src/variant.h +++ b/src/variant.h @@ -27,11 +27,7 @@ // Use custom_config.ini to set the needed variant! // If set, the firmware is build for the OBSPro hardware variant -// The main differences are: -// - The button is inverted -// - The button is also responsible for soft-power-off -// - The display is a JHD12864-G156BT which is SPI based -// - The ultrasonic sensors are PGA460 based +// The main difference is the ultrasonic sensors being PGA460 based //#define OBSPRO // If set, the firmware is build for the OBSClassic @@ -39,9 +35,6 @@ // Settings specific to OBSPro #ifdef OBSPRO -#define LCD_CS_PIN 12 -#define LCD_DC_PIN 27 -#define LCD_RESET_PIN 4 #define SENSOR1_SCK_PIN 25 #define SENSOR1_MOSI_PIN 33 @@ -49,7 +42,7 @@ #define SENSOR2_SCK_PIN 14 #define SENSOR2_MOSI_PIN 15 -#define SENSOR2_MISO_PIN 21 +#define SENSOR2_MISO_PIN 26 #define UBX_M10 #define POWER_KEEP_ALIVE_INTERVAL_MS 5000UL diff --git a/src/writer.cpp b/src/writer.cpp index dc51cc1e..42dde2ed 100644 --- a/src/writer.cpp +++ b/src/writer.cpp @@ -127,7 +127,7 @@ bool CSVFileWriter::writeHeader(String trackId) { header += "OBSFirmwareVersion=" + String(OBSVersion) + "&"; #ifdef OBSPRO header += "HardwareType=OBSPro&"; - header += "HardwareRev=v2.1&"; // TODO: Use hardware revision detection + header += "HardwareRev=v2.2&"; // TODO: Use hardware revision detection #endif #ifdef OBSCLASSIC header += "HardwareType=OBSClassic&"; From f1b739697614e4df6c76d032cc3f9f4bbe0147ac Mon Sep 17 00:00:00 2001 From: Clemens Nowitzki Date: Sat, 21 Feb 2026 12:41:32 +0100 Subject: [PATCH 2/4] Revert all irrelevant formatting changes --- src/displays.h | 4 ---- src/gps.cpp | 15 ++++++--------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/displays.h b/src/displays.h index e309634e..e469c107 100644 --- a/src/displays.h +++ b/src/displays.h @@ -61,16 +61,12 @@ class DisplayDevice { private: void handleHighlight(); void displaySimple(uint16_t value); - U8G2* m_display = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0, U8X8_PIN_NONE); // original OBSClassic display - String gridText[ 4 ][ 6 ]; uint8_t mLastProgress = 255; uint8_t mCurrentLine = 0; bool mInverted = false; - bool mFlipped = true; - uint32_t mHighlightTill = 0; bool mHighlighted = false; diff --git a/src/gps.cpp b/src/gps.cpp index 79a6b2f4..a99441bd 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -82,14 +82,14 @@ void Gps::begin() { if (!is_neo6()) log_i("Coldstart because we found that newer neos profit from that."); coldStartGps(); - } + } pollStatistics(); #endif if (is_neo6()) { enableAlpIfDataIsAvailable(); } - + if (mLastTimeTimeSet == 0) { #ifdef UBX_M10 setMessageInterval(UBX_CFG_KEY_ID::CFG_MSGOUT_UBX_NAV_TIMEGPS_UART1, 1); @@ -109,7 +109,6 @@ void Gps::begin() { //Serial.updateBaudRate(9600); //mSerial.begin(9600, SERIAL_8N1); // Debug - forward gps serial to normal serial - /* log_e("--------_STARTING LOOP"); while(1) @@ -120,8 +119,7 @@ void Gps::begin() { val = Serial.read(); if(val >= 0) mSerial.write(val); - } - */ + }*/ } void Gps::sendUbx(UBX_MSG ubxMsgId, const uint8_t payload[], uint16_t length) { @@ -275,7 +273,7 @@ void Gps::configureGpsModule() { bool success = sendAndWaitForAck(UBX_MSG::CFG_GNSS, UBX_CFG_GNSS, sizeof(UBX_CFG_GNSS)); if (success) { addStatisticsMessage("Successfully set GNSS"); - } + } else { addStatisticsMessage("GNSS not configured, likely older GPS"); } @@ -359,7 +357,7 @@ void Gps::softResetGps() { void Gps::coldStartGps() { log_i("Cold-Start GPS!"); handle(); - const uint8_t UBX_CFG_RST[] = {0xFF, 0xFF, 0x00, 0x00}; + const uint8_t UBX_CFG_RST[] = {0xFF, 0xFF, 0x00, 0x00}; // we had the case where the reset took several seconds // see https://github.com/openbikesensor/OpenBikeSensorFirmware/issues/309 // Newer firmware (like M10 and likely also M8) will not ack this @@ -580,8 +578,7 @@ bool Gps::sendAndWaitForAck(UBX_MSG ubxMsgId, const uint8_t *buffer, size_t size log_w("Retry to send 0x%04x after %dms.", ubxMsgId, millis() - loopStart); } if (result) { - //log_d("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start); - log_e("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start); + log_d("Success in sending. 0x%04x took %dms", ubxMsgId, millis() - start); } else { log_e("Failed to send. 0x%04x NAK: %d after %dms", ubxMsgId, mNakReceived, millis() - start); } From 62ff693cbdf394dc3d956e86dbc57606ada88b6a Mon Sep 17 00:00:00 2001 From: Andreas Mandel Date: Sat, 21 Feb 2026 15:11:45 +0100 Subject: [PATCH 3/4] Update workflow components & sonar-scanner. --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/codeql-analysis.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec426350..e07e0607 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: # could use a container with sq tools already installed image: infinitecoding/platformio-for-ci:latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: 0 @@ -63,11 +63,11 @@ jobs: echo $VERSION > version.txt echo Building OBS Version: $VERSION sed -i 's|-DBUILD_NUMBER=\\"-dev\\"|-DBUILD_NUMBER=\\"'${SEPARATOR}${PATCH}'\\"|' platformio.ini - echo "SONAR_SCANNER_VERSION=7.1.0.4889" >> $GITHUB_ENV + echo "SONAR_SCANNER_VERSION=8.0.1.6346" >> $GITHUB_ENV - name: Cache SonarCloud packages id: cache-sonar - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: | ~/.sonar/cache @@ -300,7 +300,7 @@ jobs: - name: Generate changelog id: changelog if: ${{ env.OBS_PREPARE_RELEASE == 'true' }} - uses: metcalfc/changelog-generator@v4.3.1 + uses: metcalfc/changelog-generator@v4 with: myToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 59845678..4e850d7a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -55,4 +55,4 @@ jobs: platformio ci --build-dir="./bin" --keep-build-dir --project-conf=platformio.ini ./src/ - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@v4 From 9778a13e356f9ca051501f1942d1f64a5a3dd641 Mon Sep 17 00:00:00 2001 From: Andreas Mandel Date: Sat, 21 Feb 2026 15:51:38 +0100 Subject: [PATCH 4/4] Update workflow codeql components --- .github/workflows/codeql-analysis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4e850d7a..460a229d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -25,15 +25,12 @@ jobs: name: Analyze runs-on: ubuntu-latest container: - # could use a container with sq tools already installed image: infinitecoding/platformio-for-ci:latest strategy: fail-fast: false matrix: - language: [ 'cpp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more: + language: [ 'cpp', 'actions' ] # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: