Skip to content

Commit

Permalink
Merge pull request #2 from FreeSK8/0.1.1
Browse files Browse the repository at this point in the history
0.1.1
  • Loading branch information
r3n33 authored Sep 8, 2021
2 parents 5ef08de + c17ae35 commit 2797b0a
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v0.1.1

* Reassign melodies
* Fix mising hapic melodies
* Fix efficiency value

v0.1.0

* Initial Beta
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# FreeSK8-Remote-Firmware

To compile follow steps 1-4 of the [ESP IDF Setup Instructions](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/index.html#setting-up-development-environment) to setup your development environment.

With ESP IDF installed execute:
```
. $HOME/esp/esp-idf/export.sh
```

then
```
idf.py -p /dev/ttyUSB0 build flash monitor
```
9 changes: 4 additions & 5 deletions main/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,10 @@ TickType_t drawScreenSecondary(TFT_t * dev, FontxFile *fx, int width, int height
{
temp_mos_previous = esc_telemetry.temp_mos;
if (user_settings->dispaly_fahrenheit) {
esc_temp_mapped = map(CTOF(esc_telemetry.temp_mos), 25, 100, 1, 20);
esc_temp_mapped = map(CTOF(esc_telemetry.temp_mos), CTOF(0), CTOF(100), 1, 20);
display_temperature = CTOF(esc_telemetry.temp_mos);
} else {
esc_temp_mapped = map(esc_telemetry.temp_mos, 25, 100, 1, 20);
esc_temp_mapped = map(esc_telemetry.temp_mos, 0, 100, 1, 20);
display_temperature = esc_telemetry.temp_mos;
}
if (display_temperature < 0) display_temperature = 0;
Expand All @@ -581,10 +581,10 @@ TickType_t drawScreenSecondary(TFT_t * dev, FontxFile *fx, int width, int height
{
temp_motor_previous = esc_telemetry.temp_motor;
if (user_settings->dispaly_fahrenheit) {
motor_temp_mapped = map(CTOF(esc_telemetry.temp_motor), 25, 100, 1, 20);
motor_temp_mapped = map(CTOF(esc_telemetry.temp_motor), CTOF(0), CTOF(100), 1, 20);
display_temperature = CTOF(esc_telemetry.temp_motor);
} else {
motor_temp_mapped = map(esc_telemetry.temp_motor, 25, 100, 1, 20);
motor_temp_mapped = map(esc_telemetry.temp_motor, 0, 100, 1, 20);
display_temperature = esc_telemetry.temp_motor;
}
if (display_temperature < 0) display_temperature = 0;
Expand Down Expand Up @@ -621,7 +621,6 @@ TickType_t drawScreenSecondary(TFT_t * dev, FontxFile *fx, int width, int height
if (user_settings->display_mph) efficiency = (esc_telemetry.watt_hours - esc_telemetry.watt_hours_charged) / (esc_telemetry.tachometer_abs / 1000.0 * KTOM);
else efficiency = (esc_telemetry.watt_hours - esc_telemetry.watt_hours_charged) / (esc_telemetry.tachometer_abs / 1000.0);
if (isnan(efficiency)) efficiency = 0;
efficiency += 10;
//TODO: Do we need a minimum distance? esc_telemetry.tachometer_abs / 1000.0 < 0.01

fontWidth = 2;
Expand Down
56 changes: 54 additions & 2 deletions main/lib/haptic/haptic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "../../esp-i2c.h"

#include "esp_log.h"

int haptic_notes=0;
int haptic_wholenote = 0;
int haptic_divider = 0;
Expand Down Expand Up @@ -63,21 +65,71 @@ void haptic_play(int index, bool interrupt_melody)
{
case MELODY_GOTCHI_FAULT:
haptic = (int*)&melody_gotchi_fault;
haptic_notes=sizeof(melody_gotchi_fault)/sizeof(melody_gotchi_fault[0])/2;
haptic_notes = sizeof(melody_gotchi_fault)/sizeof(melody_gotchi_fault[0])/2;
haptic_wholenote = (60000 * 4) / tempo_gotchi_fault;
break;
case MELODY_ESC_FAULT:
haptic = (int*)&melody_esc_fault;
haptic_notes = sizeof(melody_esc_fault)/sizeof(melody_esc_fault[0])/2;
haptic_wholenote = (60000 * 4) / tempo_esc_fault;
break;
case MELODY_BLE_FAIL:
haptic = (int*)&melody_ble_fail;
haptic_notes = sizeof(melody_ble_fail)/sizeof(melody_ble_fail[0])/2;
haptic_wholenote = (60000 * 4) / tempo_ble_fail;
break;
case MELODY_BLE_SUCCESS:
haptic = (int*)&melody_ble_success;
haptic_notes = sizeof(melody_ble_success)/sizeof(melody_ble_success[0])/2;
haptic_wholenote = (60000 * 4) / tempo_ble_success;
break;
case MELODY_STORAGE_LIMIT:
haptic = (int*)&melody_storage_limit;
haptic_notes = sizeof(melody_storage_limit)/sizeof(melody_storage_limit[0])/2;
haptic_wholenote = (60000 * 4) / tempo_storage_limit;
break;
case MELODY_ESC_TEMP:
haptic = (int*)&melody_esc_temp;
haptic_notes = sizeof(melody_esc_temp)/sizeof(melody_esc_temp[0])/2;
haptic_wholenote = (60000 * 4) / tempo_esc_temp;
break;
case MELODY_MOTOR_TEMP:
haptic = (int*)&melody_motor_temp;
haptic_notes = sizeof(melody_motor_temp)/sizeof(melody_motor_temp[0])/2;
haptic_wholenote = (60000 * 4) / tempo_motor_temp;
break;
case MELODY_VOLTAGE_LOW:
haptic = (int*)&melody_voltage_low;
haptic_notes = sizeof(melody_voltage_low)/sizeof(melody_voltage_low[0])/2;
haptic_wholenote = (60000 * 4) / tempo_voltage_low;
break;
case MELODY_LOG_START:
haptic = (int*)&melody_ascending;
haptic_notes = sizeof(melody_ascending)/sizeof(melody_ascending[0])/2;
haptic_wholenote = (60000 * 4) / tempo_ascending;
break;
case MELODY_LOG_STOP:
haptic = (int*)&melody_descending;
haptic_notes = sizeof(melody_descending)/sizeof(melody_descending[0])/2;
haptic_wholenote = (60000 * 4) / tempo_descending;
break;
case MELODY_STARTUP:
haptic = (int*)&melody_startup;
haptic_notes = sizeof(melody_startup)/sizeof(melody_startup[0])/2;
haptic_wholenote = (60000 * 4) / tempo_startup;
break;
case MELODY_GPS_LOCK:
haptic = (int*)&melody_gps_locked;
haptic_notes = sizeof(melody_gps_locked)/sizeof(melody_gps_locked[0])/2;
haptic_wholenote = (60000 * 4) / tempo_gps_locked;
break;
case MELODY_GPS_LOST:
haptic = (int*)&melody_gps_lost;
haptic_notes = sizeof(melody_gps_lost)/sizeof(melody_gps_lost[0])/2;
haptic_wholenote = (60000 * 4) / tempo_gps_lost;
break;
default:
//TODO: add default haptic
ESP_LOGW(__FUNCTION__,"Invalid index %d", index);
break;
}

Expand Down
5 changes: 2 additions & 3 deletions main/lib/melody/melody.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "melody.h"
#include "esp_log.h"
#include "driver/ledc.h"

int melody_notes=0;
Expand Down Expand Up @@ -105,7 +106,6 @@ void melody_play(int index, bool interrupt_melody)
melody_wholenote = (60000 * 4) / tempo_descending;
break;
case MELODY_STARTUP:
printf("melody startup received\n");
melody = (int*)&melody_startup;
melody_notes=sizeof(melody_startup)/sizeof(melody_startup[0])/2;
melody_wholenote = (60000 * 4) / tempo_startup;
Expand All @@ -121,7 +121,7 @@ void melody_play(int index, bool interrupt_melody)
melody_wholenote = (60000 * 4) / tempo_gps_lost;
break;
default:
//TODO: add default melody
ESP_LOGW(__FUNCTION__,"Invalid index %d", index);
break;
}

Expand All @@ -145,7 +145,6 @@ void melody_step(void)
melody_this_note = 0;
is_melody_playing = false;
ledc_stop(LEDC_HIGH_SPEED_MODE, LEDC_CHANNEL, 0);
printf("end of melody\n");
return;
}

Expand Down
17 changes: 10 additions & 7 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "lib/haptic/haptic.h"

const char * version = "0.1.0";
const char * version = "0.1.1";

int gyro_x, gyro_y, gyro_z;
float accel_g_x, accel_g_x_delta;
Expand Down Expand Up @@ -256,15 +256,18 @@ static void gpio_input_task(void* arg)
}
if ((ev.pin == GPIO_INPUT_IO_0) && (ev.event == BUTTON_DOUBLE_CLICK)) {
// SW3 on HW v1.2 PCB
melody_play(MELODY_STARTUP, true);
haptic_play(MELODY_STARTUP, true);
is_throttle_locked = !is_throttle_locked; // Toggle throttle lock
if (is_throttle_locked)
{
display_blank_now = true; // Clear display
display_second_screen = false; // Request primary screen with throttle locked
melody_play(MELODY_GPS_LOST, true);
haptic_play(MELODY_GPS_LOST, true);
} else {
display_blank_now = true; // Clear the display if we turn off throttle lock
melody_play(MELODY_GPS_LOCK, true);
haptic_play(MELODY_GPS_LOCK, true);
}
else display_blank_now = true; // Clear the display if we turn off throttle lock
ESP_LOGI(__FUNCTION__, "Throttle lock is %d", is_throttle_locked);
}
if ((ev.pin == GPIO_INPUT_IO_1) && (ev.event == BUTTON_DOWN)) {
Expand All @@ -274,8 +277,8 @@ static void gpio_input_task(void* arg)
// SW2 on HW v1.2 PCB
}
if ((ev.pin == GPIO_INPUT_IO_3) && (ev.event == BUTTON_HELD)) {
melody_play(MELODY_GPS_LOST, true);
haptic_play(MELODY_GPS_LOST, true);
melody_play(MELODY_LOG_STOP, true);
haptic_play(MELODY_LOG_STOP, true);
ESP_LOGI(__FUNCTION__, "Setting MCU_LATCH to 0");
/// Turn Power switch LED off
gpio_set_level(GPIO_OUTPUT_IO_0, 0);
Expand Down Expand Up @@ -384,7 +387,7 @@ static void i2c_task(void *arg)
}
if (!gpio_usb_detect)
{
// Check if we've been idle for more than 5 seconds
// Check if throttle has been idle for more than 5 minutes
if ((xTaskGetTickCount() - startTickThrottleIdle)*portTICK_RATE_MS > 5 * 60 * 1000)
{
is_throttle_idle = true;
Expand Down

0 comments on commit 2797b0a

Please sign in to comment.