Skip to content

Commit

Permalink
First commit with dual motor support, tested on Fiido Q1S
Browse files Browse the repository at this point in the history
  • Loading branch information
casainho committed Apr 28, 2024
1 parent 288592b commit ca4e927
Show file tree
Hide file tree
Showing 12 changed files with 423 additions and 183 deletions.
4 changes: 2 additions & 2 deletions diy_main_board/firmware/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"python.analysis.extraPaths": [
"",
"/home/cas/.vscode/extensions/joedevivo.vscode-circuitpython-0.2.0-linux-x64/stubs",
"/home/cas/.config/Code/User/globalStorage/joedevivo.vscode-circuitpython/bundle/20240402/adafruit-circuitpython-bundle-py-20240402/lib"
"/home/cas/.config/Code/User/globalStorage/joedevivo.vscode-circuitpython/bundle/20240428/adafruit-circuitpython-bundle-py-20240428/lib"
],
"circuitpython.board.version": "8.2.0-5-gfad86bfb2-dirty"
"circuitpython.board.version": "9.0.3"
}
8 changes: 4 additions & 4 deletions diy_main_board/firmware/boot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# import storage
# storage.disable_usb_drive()
# storage.remount("/", readonly=False)
# storage.enable_usb_drive()
import storage
storage.disable_usb_drive()
storage.remount("/", readonly=False)
storage.enable_usb_drive()
13 changes: 13 additions & 0 deletions diy_main_board/firmware/ebike_bafang_m500/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"python.languageServer": "Pylance",
"python.analysis.diagnosticSeverityOverrides": {
"reportMissingModuleSource": "none",
"reportShadowedImports": "none"
},
"python.analysis.extraPaths": [
"",
"/home/cas/.vscode/extensions/joedevivo.vscode-circuitpython-0.2.0-linux-x64/stubs",
"/home/cas/.config/Code/User/globalStorage/joedevivo.vscode-circuitpython/bundle/20240402/adafruit-circuitpython-bundle-py-20240402/lib"
],
"circuitpython.board.version": null
}
13 changes: 13 additions & 0 deletions diy_main_board/firmware/escooter_fiido_q1_s/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"python.languageServer": "Pylance",
"python.analysis.diagnosticSeverityOverrides": {
"reportMissingModuleSource": "none",
"reportShadowedImports": "none"
},
"python.analysis.extraPaths": [
"",
"/home/cas/.vscode/extensions/joedevivo.vscode-circuitpython-0.2.0-linux-x64/stubs",
"/home/cas/.config/Code/User/globalStorage/joedevivo.vscode-circuitpython/bundle/20240411/adafruit-circuitpython-bundle-py-20240411/lib"
],
"circuitpython.board.version": null
}
12 changes: 6 additions & 6 deletions diy_main_board/firmware/escooter_fiido_q1_s/display_espnow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
class Display(object):
"""Display"""

def __init__(self, display_mac_address, system_data):
self._system_data = system_data
def __init__(self, display_mac_address, vars):
self._vars = vars
self._espnow = ESPNow.ESPNow()
peer = ESPNow.Peer(mac=bytes(display_mac_address), channel=1)
self._espnow.peers.append(peer)
Expand All @@ -31,15 +31,15 @@ def process_data(self):
# only process packages for us
# must have 3 elements: message_id + 2 variables
if int(data_list[0]) == int(BoardsIds.MAIN_BOARD) and len(data_list) == 3:
self._system_data.motor_enable_state = True if data_list[1] != 0 else False
self._system_data.button_power_state = data_list[2]
self._vars.motor_enable_state = True if data_list[1] != 0 else False
self._vars.button_power_state = data_list[2]
except:
pass

def update(self):
if self._espnow is not None:
try:
brakes_are_active = 1 if self._system_data.brakes_are_active else 0
self._espnow.send(f"{int(BoardsIds.DISPLAY)} {int(self._system_data.battery_voltage_x10)} {int(self._system_data.battery_current_x100)} {int(self._system_data.motor_current_x100)} {int(self._system_data.wheel_speed * 10)} {int(brakes_are_active)} {int(self._system_data.vesc_temperature_x10)} {int(self._system_data.motor_temperature_x10)}")
brakes_are_active = 1 if self._vars.brakes_are_active else 0
self._espnow.send(f"{int(BoardsIds.DISPLAY)} {int(self._vars.battery_voltage_x10)} {int(self._vars.battery_current_x100)} {int(self._vars.motor_current_x100)} {int(self._vars.wheel_speed * 10)} {int(brakes_are_active)} {int(self._vars.vesc_temperature_x10)} {int(self._vars.motor_temperature_x10)}")
except:
pass
Loading

0 comments on commit ca4e927

Please sign in to comment.