Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Added lights current ADC step configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
casainho committed Apr 28, 2020
1 parent 1e09de3 commit 7b2bde9
Show file tree
Hide file tree
Showing 6 changed files with 267 additions and 254 deletions.
2 changes: 2 additions & 0 deletions firmware/common/include/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ typedef struct eeprom_data {

uint8_t ui8_pedal_cadence_fast_stop;
uint8_t ui8_coast_brake_adc;
uint8_t ui8_adc_lights_current_offset;

// FIXME align to 32 bit value by end of structure and pack other fields
} eeprom_data_t;
Expand Down Expand Up @@ -269,6 +270,7 @@ void eeprom_init_defaults(void);
#define DEFAULT_PEDAL_CADENCE_FAST_STOP_ENABLE 1 // enabled
#define DEFAULT_COAST_BRAKE_ADC 15 // 15: tested by plpetrov user on 28.04.2020:
#define DEFAULT_FIELD_WEAKENING 1 // 1 enabled
#define DEFAULT_ADC_LIGHTS_CURRENT_OFFSET 0

#define BICYCLE_1
//#define BICYCLE_2
Expand Down
4 changes: 4 additions & 0 deletions firmware/common/include/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ typedef struct rt_vars_struct {

uint8_t ui8_pedal_cadence_fast_stop;
uint8_t ui8_coast_brake_adc;
uint8_t ui8_adc_lights_current_offset;
uint16_t ui16_adc_battery_current;

battery_energy_h_km_t battery_energy_h_km;
} rt_vars_t;
Expand Down Expand Up @@ -338,6 +340,8 @@ typedef struct ui_vars_struct {

uint8_t ui8_pedal_cadence_fast_stop;
uint8_t ui8_coast_brake_adc;
uint8_t ui8_adc_lights_current_offset;
uint16_t ui16_adc_battery_current;
} ui_vars_t;

ui_vars_t* get_ui_vars(void);
Expand Down
4 changes: 2 additions & 2 deletions firmware/common/include/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ const uint8_t* uart_get_rx_buffer_rdy(void);
uint8_t* uart_get_tx_buffer(void);
void uart_send_tx_buffer(uint8_t *tx_buffer, uint8_t ui8_len);

#define UART_NUMBER_DATA_BYTES_TO_RECEIVE 28
#define UART_NUMBER_DATA_BYTES_TO_SEND 85
#define UART_NUMBER_DATA_BYTES_TO_RECEIVE 29
#define UART_NUMBER_DATA_BYTES_TO_SEND 86

4 changes: 2 additions & 2 deletions firmware/common/src/configscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ static Field displayMenus[] =
FIELD_EDITABLE_UINT(_S("Auto power off", "Auto p off"), &ui_vars.ui8_lcd_power_off_time_minutes, "mins", 0, 255),
FIELD_EDITABLE_ENUM("Units", &ui_vars.ui8_units_type, "SI", "Imperial"),
#ifndef SW102
// FIELD_READONLY_STRING("Display firmware", ""),
// FIELD_READONLY_STRING("TSDZ2 firmware", ""),
FIELD_READONLY_ENUM("LCD type", &g_lcd_ic_type, "ILI9481", "ST7796", "unknown"),
#endif
FIELD_EDITABLE_ENUM(_S("Reset to defaults", "Reset def"), &ui8_g_configuration_display_reset_to_defaults, "no", "yes"),
Expand All @@ -190,6 +188,7 @@ static Field displayMenus[] =
static Field variousMenus[] = {
FIELD_EDITABLE_ENUM(_S("Cadence fast stop", "Cadenc stp"), &ui_vars.ui8_pedal_cadence_fast_stop, "no", "yes"),
FIELD_EDITABLE_UINT(_S("Coast brake ADC", "Coa bk ADC"), &ui_vars.ui8_coast_brake_adc, "", 5, 255),
FIELD_EDITABLE_UINT(_S("ADC lights offset", "ADC lights"), &ui_vars.ui8_adc_lights_current_offset, "", 0, 4),
FIELD_EDITABLE_ENUM(_S("Assist w/o pedal rot", "A w/o ped"), &ui_vars.ui8_motor_assistance_startup_without_pedal_rotation, "disable", "enable"), // FIXME, share one array of disable/enable strings
FIELD_EDITABLE_UINT("Odometer", &ui_vars.ui32_odometer_x10, "km", 0, UINT32_MAX, .div_digits = 1, .inc_step = 100, .onSetEditable = onSetConfigurationWheelOdometer),
FIELD_END };
Expand Down Expand Up @@ -341,6 +340,7 @@ static Field variablesMenus[] = {
#endif

static Field technicalMenus[] = {
FIELD_READONLY_UINT(_S("ADC battery current", "ADC bat cu"), &ui_vars.ui16_adc_battery_current, ""),
FIELD_READONLY_UINT(_S("ADC throttle sensor", "ADC thrott"), &ui_vars.ui8_adc_throttle, ""),
FIELD_READONLY_UINT(_S("Throttle sensor", "Throttle s"), &ui_vars.ui8_throttle, ""),
FIELD_READONLY_UINT(_S("ADC torque sensor", "ADC torque"), &ui_vars.ui16_adc_pedal_torque_sensor, ""),
Expand Down
Loading

0 comments on commit 7b2bde9

Please sign in to comment.