Coder Social home page Coder Social logo

atctwo / watch-ii Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 55.81 MB

Firmware for my custom smart-ish-watch, mark II

License: MIT License

C++ 59.61% C 36.94% Python 0.24% CMake 0.92% Makefile 0.17% HTML 0.70% Shell 0.09% OpenSCAD 1.32%
arduino esp32 watch

watch-ii's People

Contributors

atctwo avatar

Stargazers

 avatar

watch-ii's Issues

power off screen during sleep

when the watch goes into sleep, the tft isn't turned off (just the backlight). maybe turn it off on sleep?????????????

audio: use library loop

when the audio is being looped, code is used to keep track of looping. there's a library function to do this, so it might be better to use that

wifi + bluetooth: run state update routines on core 0

It might be a good idea to run the wifi and bluetooth state update routines on core 0. Currently, the run in the end loop method on core 1, and take up some of core 1's processor time. If the routines run on core 0, they can run independent of core 1, and if core 1 is busy (eg: music player) the wifi and bluetooth states can still be updated. This might cause issues with wifi and bluetooth, because their tasks will have to share processor time with the state tasks.

Very long term todo list

This isn't really an issue concerning one specific thing; it's just a big list of ideas or things i want to research or implement. If an item is feasible, and has been mostly implemented (to a usable degree), it will be checked off the list. A lot of more specific or small or existing in-development improvements aren't listed here, but are probably listed as a separate issue

watch2 system core

  • use framebuffers
  • BLE subsystem
    • implementation started, but on hold for now
  • Micropython or CircuitPython

software stuff (like interface features and apps)

  • weather api integration
    • current weather on the ripoff control centre (2ed6a07)
    • weather app (bf76c7c)
  • static map app
  • UPC api app
  • BLE remote control app (a6470b0)
  • more games
    • tetris (36e4e25)
    • breakout
    • blackjack?
    • maybe port emulators?
      • NES, doesn't run very well (cb17ff9)
    • quiz game (using Open Trivia API) (2ed6a07 and 3ed3e03)

hardware stuff

  • use a TFT
  • [x ] I2S amplifier + speaker
    • i still need to find a small enclosed speaker to embed on the watch2 mainboard
  • I2S microphone
    • depends on I2S amplifier
  • 9-dof sensor
    • might just add a magnetomoter?
  • NFC / RFID
    • will probably use the STEMMA QT extension port
    • could use this
    • might be able to use this
  • temperature sensor (and/or other environmental sensors)
    • i'll probably use one built into a imu sensor
    • or an MCP9808
  • STEMMA QT expansion port
  • IR remote sending / receiving
  • USB-C power
  • new 5 way switch (the one i started with has been discontinued)
  • lipo battery + charge controller
  • fuel gauge
  • on/off supervisor
    • uses MAX16150 (half working shutdown button added in 1afc083)
  • touch screen??? probably not

watch os: add message boxes

i could add message boxes based on the on screen keyboard. i want to have an interface that lets you specify custom buttons, or just a yes/no box, or just an "ok" box.

use DMA for drawing icons

icons are now loaded from spiffs into ram, and drawn using the drawImage() function. this function uses TFT_eSPI::drawPixel() for each pixel, so this could probably be rewritten or modified to use DMA methods, like TFT_eSPI::pushPixelsDMA().

NTP: ignores timezone

Whenever NTP gets the time, it always assumes the timezone is set to 0, even if it set to something that isn't 0 in the settings app.

Small Icon loading

maybe load small icons into a structure in psram from spiffs (like the app icons). this might reduce heap usage???

music player: format support

The library used for audio playback (https://github.com/earlephilhower/ESP8266Audio) supports loads of different file formats and stream types. Here is a list of what the watch 2 music player app supports (ie: what does the app have an interface for).

format supported date support added performance
AAC [x] 08.06.20 pretty good, crackly
FLAC [ ] doesn't make any sound
MIDI [ ] crashes ESP
RTTTL [ ]
WAV [x]ย  08.06.20 awful (dependant on file?)
MP3 [x] 30.05.20 pretty good
MOD [x] 08.06.20 pretty good, quiet, doesn't work with .it or .xm files
HTTP streams [ ]
ICY streams [ ]

music: return to the same directory

when you have stopped playing a song, return to the directory the music file was in. this might be an issue with the file browser dialogue, though... ๐ŸŽต

clear settings no longer works

the clear settings dialogue when holding down and waking the watch up doesn't work anymore. no matter what the user selects, the settings will not be erased

wifi: profiles are broken

if the profile list file doesn't contain valid json, then profiles aren't loaded at all. this has a knock-on effect, meaning that most operations that involve profiles fail (including appending profiles).

Doxygen documentation

I really want to write actual documentation for the watch2 namespace members in watch2.h, and maybe system documentation about how the system works.

Add boot screen

I rely on debug messages being printed over serial to see what's happening when the device is booting (and if any errors occur). Adding a boot screen to the TFT would add another visual boot indicator (and it would look nice)

watch os: add numeric keypad

add a numeric keypad that let's you enter numbers and maybe some symbols. it could be a popup dialogue, like the keyboard. I don't really need one yet, but it might be useful later.

Reset Screen on wakeup

In case the screen doesn't turn back on properly on wakeup, you could pull the tft reset pin low for a bit, qnd reinit the screen. idk if that would add wakeup time or mess up TFT_eSPI.

fading doesn't work

Commit 2e6735d mostly works, although the tft backlight brightness isn't being changed when switching states. You can still set the maximum brightness and torch brightness, so ledc probably still works.

MicroPython app

I still want to make a micropython app, and I tried to get micropython working as an arduino library, but there were many issues with that. Now that the project uses ESP-IDF, it might be a lot easier to build micropython as part of the watch, and it might be easier to link to and use.

Also, this repo might help: https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo

ripoff control centre: move to pop up window

The on screen keyboard shows that the system can have pop up windows. I think the control centre could be moved to a pop up window so that it can be accessed from every app. it will need a way to open it, one idea is having a capacitive touch panel at the top of the screen? this could also be used to implement a kind of notifications system.

calculator: can't go left or right

you can't select any box to the left or right of the currently selected box (though you can go up and down) in the calculator app. this isn't an issue in the ir remote app.

menu dialogue: only draw items in focus

it means that lists with loads of items take ages to draw, making scrolling really awkward
maybe don't draw items if their y is less than 0 or their y is greater than screen height.

look into littlevgl

maybe use littlevgl for more stable gui stuff
this would rely on #5 working and not eating too much current

weather: location not set error

It would be cool to add a error message to the weather app. if you haven't set a location, show a message that says "please set or a location" (or just skip straight to the location selection screen)

also, i should implement something similar for "not connected to wifi"

add file info to sd test

you could add file info to the sd test app, and use it as a kind of "file browser". if you add a file association system, you could have an open with button. file details could include

  • file path
  • file size
  • mime type?
  • date modified
  • date created
  • attributes
  • open with

maybe print any metadata that the file has?

watch icons: maybe use an icon set

I can't design my own icons, because they look awful. Mabe i could use an existing icon set (like Papyrus). These icons will probably be in SVG format, so it might be a good idea to load the SVGs into memory on system boot (from SPIFFS or SD).

calculator: move tinyexpr from Arduino library to src folder

currently, tinyexpr is installed as a custom arduino library, meaning that people who want to build the system from scratch have to install it themselves. it would make more sense to include tinyexpr's source in the src directory of the sketch. this means that users can install one less library

PCB version 2 checklist

Here's a list of things I should do when designing v2 of the PCB:

bugs

  • switch transistor pinout
  • add MCP9808T temperature sensor
  • reverse tft header
  • stemma qt pinout
  • ground mcp23008 address pins
  • usb-c data pins
  • mcp73831 led source -> sink

improvements

  • move side switch to left side of board (if possible)
  • move reset button to bottom side of board
  • switch fuel gauge to LC709203F
  • change LED resistor footprints
  • add 3v3, gnd, rx, tx pins
  • remove dpad_enter transistor, replace with button to ground
  • base resistors 1k -> 330R
  • pcb shorting thing under resistors

music player: performance under certain conditions

I'm experimenting with the music player app, using an I2S amplifier (max98357a), and there are some differences in the sound reproduction and watch system functioning depending on how the audio task is configured.

Core Priority Task Delay Audio Quality TFT watch main loop
1 2 0 Perfect breaks doesn't execute
1 2 1 mostly ok breaks executes
0 max - 2 1 really bad works doesn't execute
0 max - 2 0 really bad works doesn't execute

I'm probably not going to get it working on core 0, so I will probably implement some system where the ESP soft resets once you exit playback. I've tried to reinit the screen after exiting, but that doesn't work. I wonder if the screen dies because the main loop is suspended while writing to the screen? I should also consider if I can update the screen from the audio loop.

Wifi + Bluetooth Coexistance

Commit 9612d23 added Bluetooth support, but weird issues arise when you try to enable Wifi and Bluetooth at the same time. I used a separate test sketch and verified that you can run Wifi and BT at the same time on the ESP32, so i think that if you are running the watch 2 system and Wifi and Bluetooth, then the internal RAM is filled up.

I can think of a few workarounds for this, but I don't really know what the best option is. For now, I'm going to disable bluetooth until I think of a good idea. Here are the ideas I've had:

  • only support one communication method. Either Wifi or Bluetooth, but not both. If this happens, I'll probably keep wifi, and leave bluetooth disabled (but I won't remove the code)
  • ensure that only wifi or bluetooth are on at any given time. that is, when wifi is on, bluetooth isn't, and vice versa. This is difficult because I can't figure out how to deallocate the memory used by bluetooth once it has been initalised, and would be a perfect option.
  • Migrate the project to an ESP-IDF project. This would mean that I could set up the SDK using custom options, and I could set options to tell the BT and Wifi stacks to use external memory (this would be amazing). I've been working on this, but there are loads of really weird errors, so it might not be feasible.

This issue might take a while to solve. I'm going to do any Bluetooth stuff in the wifi_bt_coex branch, so new states and stuff can be worked on in the master branch (or another specialised branch).

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Also, i'm an idiot, and the commit that adds bluetooth support removes wifi profile support so when merging that branch remember this you idiot

pass stateMeta struct to app functions

The main loop should pass the stateMeta of the current app to the function for the current app. You could refer to the current state using state rather than watch2::states[watch2::state].

ir remote json object memory

at the minute, the json deserialisation object has 10k of heap memory, which is freed after the profile data is copied into the blah blah data structures. maybe try to calculate how much memory the json profile would need at runtime? fix it fix it fix it fix it except it isn't really broken, i just think there could be a more efficient way to do the thing

move system functions to watch2 class

at the moment, all the system functions are defined in one file (watch2.ino), and things are specifically targeted to the esp32. at some point, the functions should be moved to a class system.
for example:
image

  • the base class (watch2) contains non-hw specific methods and method stubs for hw specific stuff
    • contains things like the state machine and switchState()
    • method prototypes for hardware specific functions
  • the base class is inherited by hardware specific classes (eg: w2_esp32) which override hardware specific methods
    • these classes could be specific to microcontrollers (eg: esp32) or boards (eg: esp32 devkit)

when compiling the watch firmware, the user can change what class is instantiated (by changing one line of code) to target different systems

NTP disabled

The code for setting the time stored by TimeLib.h after getting the time using NTP was disabled because it threw compiler errors that I didn't want to fix as part of moving to ESP-IDF (2e6735d, #17). The code still exists but is commented out.

watch face: takes a while to wake up from sleep

it takes a while for the watch to wake up from sleep, i think it's because the sprite that shows the time is taking ages to render before the brightness is turned up. idk what do do about this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.