Skip to content

Commit

Permalink
Implement review hints of rovo89
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehaenger committed Oct 11, 2024
1 parent 68ed301 commit bca5826
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
#define V_CHARGE_ABS_MAX 40.0f // Absolute max. limited by D2/D3 Schottky
#define I_CHARGE_ABS_MAX 5.0f // Absolute max. limited by D2/D3 Schottky

#define RAIN_THRESHOLD 700U // (Yet) Stock-CoverUI exclusive raw ADC value. Is the measured value is lower, it rains

#define SOUND_VOLUME 80 // Volume (0-100%)
#define LANGUAGE 'e', 'n' // ISO 639-1 (2-char) language code (en, de, ...)

#endif // _CONFIG_H
28 changes: 14 additions & 14 deletions Firmware/LowLevel/src/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define _DATATYPES_H

#include <stdint.h>
#include "config.h"
#include "config_defaults.h"

#define PACKET_ID_LL_STATUS 1
#define PACKET_ID_LL_IMU 2
Expand Down Expand Up @@ -143,16 +143,16 @@ struct ll_ui_event {
typedef char iso639_1[2]; // Two char ISO 639-1 language code

enum class HallMode : uint8_t {
off = 0,
emergency, // Triggers emergency with lift & tilt functionality
stop, // Stop mower
pause // Pause the mower (not yet implemented in ROS)
OFF = 0,
EMERGENCY, // Triggers emergency with lift & tilt functionality
STOP, // Stop mower
PAUSE // Pause the mower (not yet implemented in ROS)
};

// FIXME: Decide later which is more comfortable, activeLow = 0 | 1
enum class HallLevel : uint8_t {
activeLow = 0, // If Hall-Sensor (or button) is active/triggered we've this level on our GPIO
activeHigh
ACTIVE_LOW = 0, // If Hall-Sensor (or button) is active/triggered we've this level on our GPIO
ACTIVE_HIGH
};

#pragma pack(push, 1)
Expand All @@ -173,21 +173,21 @@ struct ll_high_level_config {
// uint8_t type; Just for illustration. Get set in wire buffer with type PACKET_ID_LL_HIGH_LEVEL_CONFIG_REQ or PACKET_ID_LL_HIGH_LEVEL_CONFIG_RSP

uint8_t config_bitmask = 0; // See LL_HIGH_LEVEL_CONFIG_BIT_*
uint16_t rain_threshold = 700; // If (stock CoverUI) rain value < rain_threshold then it rains. Expected to differ between C500, SA and SC types
uint16_t rain_threshold = RAIN_THRESHOLD; // If (stock CoverUI) rain value < rain_threshold then it rains. Expected to differ between C500, SA and SC types
float v_charge_cutoff = V_CHARGE_MAX; // Protective max. charging voltage before charging get switched off
float i_charge_cutoff = I_CHARGE_MAX; // Protective max. charging current before charging get switched off
float v_battery_cutoff = V_BATT_CUTOFF; // Protective max. battery voltage before charging get switched off
float v_battery_empty = BATT_EMPTY; // Empty battery voltage used for % calc of capacity
float v_battery_full = BATT_FULL; // Full battery voltage used for % calc of capacity
uint16_t lift_period = LIFT_EMERGENCY_MILLIS; // Period (ms) for both wheels to be lifted in order to count as emergency (0 disable, 0xFFFF do not change). This is to filter uneven ground
uint16_t tilt_period = TILT_EMERGENCY_MILLIS; // Period (ms) for a single wheel to be lifted in order to count as emergency (0 disable, 0xFFFF do not change). This is to filter uneven ground
iso639_1 language = {'e', 'n'}; // ISO 639-1 (2-char) language code (en, de, ...)
int8_t volume = 80; // Volume (0-100%) feedback (if directly changed i.e. via CoverUI or WebApp)
iso639_1 language = {LANGUAGE}; // ISO 639-1 (2-char) language code (en, de, ...)
int8_t volume = SOUND_VOLUME; // Volume (0-100%) feedback (if directly changed i.e. via CoverUI or WebApp)
HallConfig hall_configs[MAX_HALL_INPUTS] = {
{HallMode::emergency, HallLevel::activeLow}, // [0] OM Hall-1 input (Lift1)
{HallMode::emergency, HallLevel::activeLow}, // [1] OM Hall-2 input (Lift2)
{HallMode::stop, HallLevel::activeLow}, // [2] OM Hall-3 input (Stop1)
{HallMode::stop, HallLevel::activeLow}, // [3] OM Hall-4 input (Stop2)
{HallMode::EMERGENCY, HallLevel::ACTIVE_LOW}, // [0] OM Hall-1 input (Lift1)
{HallMode::EMERGENCY, HallLevel::ACTIVE_LOW}, // [1] OM Hall-2 input (Lift2)
{HallMode::STOP, HallLevel::ACTIVE_LOW}, // [2] OM Hall-3 input (Stop1)
{HallMode::STOP, HallLevel::ACTIVE_LOW}, // [3] OM Hall-4 input (Stop2)
// [4] Stock-CoverUI-1 ... [9] Stock-CoverUI-6 defaults to off
};
// INFO: Before adding a new member here: Decide if and how much hall_configs spares do we like to have
Expand Down
4 changes: 1 addition & 3 deletions Firmware/LowLevel/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <FastCRC.h>
#include <PacketSerial.h>
#include "datatypes.h"
#include "config.h"
#include "config_defaults.h"
#include "pins.h"
#include "ui_board.h"
#include "imu.h"
Expand Down Expand Up @@ -366,9 +366,7 @@ void setup() {
// Therefore, we pause the other core until setup() was a success
rp2040.idleOtherCore();

#ifdef USB_DEBUG
DEBUG_BEGIN(9600);
#endif

emergency_latch = true;
ROS_running = false;
Expand Down

0 comments on commit bca5826

Please sign in to comment.