Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions internal_filesystem/lib/mpos/board/odroid_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import lvgl as lv
import machine
import mpos.ui
from machine import ADC, Pin
from machine import ADC, PWM, Pin
from micropython import const
from mpos import InputManager
from mpos import AudioManager, BatteryManager, InputManager

# Display settings:
SPI_HOST = const(1)
Expand Down Expand Up @@ -49,14 +49,26 @@
# Misc settings:
LED_BLUE = const(2)
BATTERY_PIN = const(36)
SPEAKER_ENABLE_PIN = const(25)
SPEAKER_PIN = const(26)

# Buzzer
BUZZER_PIN = const(26)
BUZZER_DAC_PIN = const(25)
BUZZER_TONE_CHANNEL = const(0)


print("odroid_go.py turn on blue LED")
blue_led = machine.Pin(LED_BLUE, machine.Pin.OUT)
blue_led.on()

print("odroid_go.py init buzzer")
buzzer = PWM(Pin(BUZZER_PIN, Pin.OUT, value=1), duty=5)
dac_pin = Pin(BUZZER_DAC_PIN, Pin.OUT, value=1)
dac_pin.value(1) # Unmute
AudioManager(i2s_pins=None, buzzer_instance=buzzer)
AudioManager.set_volume(40)
AudioManager.play_rtttl("Star Trek:o=4,d=20,b=200:8f.,a#,4d#6.,8d6,a#.,g.,c6.,4f6")
while AudioManager.is_playing():
time.sleep(0.1)

print("odroid_go.py machine.SPI.Bus() initialization")
try:
Expand Down Expand Up @@ -102,24 +114,23 @@


print("odroid_go.py Battery initialization...")
from mpos import BatteryManager


def adc_to_voltage(raw_adc_value):
"""
The percentage calculation uses MIN_VOLTAGE = 3.15 and MAX_VOLTAGE = 4.15
0% at 3.15V -> raw_adc_value = 270
0% at 3.15V -> raw_adc_value = 210
100% at 4.15V -> raw_adc_value = 310

4.15 - 3.15 = 1V
310 - 270 = 40 raw ADC steps
310 - 210 = 100 raw ADC steps

So each raw ADC step is 1V / 40 = 0.025V
So each raw ADC step is 1V / 100 = 0.01V
Offset calculation:
270 * 0.025 = 6.75V. but we want it to be 3.15V
So the offset is 3.15V - 6.75V = -3.6V
210 * 0.01 = 2.1V. but we want it to be 3.15V
So the offset is 3.15V - 2.1V = 1.05V
"""
voltage = raw_adc_value * 0.025 - 3.6
voltage = raw_adc_value * 0.01 + 1.05
return voltage


Expand Down Expand Up @@ -198,6 +209,13 @@ def input_callback(indev, data):
elif button_volume.value() == 0:
print("Volume button pressed -> reset")
blue_led.on()
AudioManager.play_rtttl(
"Outro:o=5,d=32,b=160,b=160:c6,b,a,g,f,e,d,c",
stream_type=AudioManager.STREAM_ALARM,
volume=40,
)
while AudioManager.is_playing():
time.sleep(0.1)
machine.reset()
elif button_select.value() == 0:
current_key = lv.KEY.BACKSPACE
Expand Down
20 changes: 14 additions & 6 deletions internal_filesystem/lib/mpos/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,28 @@ def detect_board():
if i2c0 := fail_save_i2c(sda=21, scl=22):
if single_address_i2c_scan(i2c0, 0x68): # IMU (MPU6886)
return "m5stack_fire"


import machine
unique_id_prefix = machine.unique_id()[0]

print("odroid_go ?")
if unique_id_prefix == 0x30:
return "odroid_go"

print("fri3d_2024 ?")
if i2c0 := fail_save_i2c(sda=9, scl=18):
if single_address_i2c_scan(i2c0, 0x6B): # IMU (plus possibly the Communicator's LANA TNY at 0x38)
return "fri3d_2024"

import machine
if machine.unique_id()[0] == 0xdc: # prototype board had: dc:b4:d9:0b:7d:80
print("fri3d_2026 ?")
if unique_id_prefix == 0xDC: # prototype board had: dc:b4:d9:0b:7d:80
# or: if single_address_i2c_scan(i2c0, 0x6A): # IMU currently not installed on prototype board
return "fri3d_2026"

print("odroid_go ?")
#if check_pins(0, 13, 27, 39): # not good because it matches other boards (like fri3d_2024 and fri3d_2026)
return "odroid_go"
raise Exception(
"Unknown ESP32-S3 board: couldn't detect known I2C devices or unique_id prefix"
)


# EXECUTION STARTS HERE

Expand Down
Loading