Commit Graph

54 Commits

Author SHA1 Message Date
ae726313a0 use shift button to change channel when held + rotate. 2025-07-04 10:44:03 -07:00
d2228af55f bug fix: must have curly braces when declaring new variables inside CASE statement. 2025-07-04 08:22:25 -07:00
d21c0a810f Add more clock mult/div options and improve documentation to make it easier to modify the list. 2025-07-03 09:12:15 -07:00
74d98fed13 add missing midi echo 2025-07-03 09:08:38 -07:00
17a9212fc4 pre-calculate clock pulse mods to improve ISR performance 2025-07-03 08:45:53 -07:00
db50132c28 update comments and minor fixes. 2025-07-03 07:57:18 -07:00
7ce8bb661d refactor cv mod to allow both cv mods configurable per channel. Fix euclidean sum mod. update large font. 2025-07-02 14:16:15 -07:00
a640723be8 minor memory improvements 2025-07-01 21:31:20 -07:00
dd1228be00 Vendorize uClock (#10)
Add copy of uClock to the repo including memory optimization changes.

Also add user config setting for changing Pulse Out resolution.

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/10
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-07-02 02:45:39 +00:00
edddfd5879 Optimize euclidean pattern by changing from an array of ints to a bitmask. 2025-07-01 12:23:50 -07:00
ceb01bf03f Introduce basic Euclidean Rhythm (#9)
Each channel can define a euclidean rhythm by setting a number of steps (up to 16) and a number of hits to evenly distribute within those steps. CV Mod is available, however the cv mod acts as an override instead of a sum mix like the other parameters.

Refactor `applyCvMod()` so it is only called if cv mod is active for that channel. Now the setter methods will update the final output value if cv mod is not active.

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/9
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-06-30 17:23:56 +00:00
6d0a9f9f7f additional refactoring, small memory reduction. 2025-06-28 09:46:50 -07:00
d56355a94b refactor encoder. no need for Dir enum. 2025-06-28 09:45:50 -07:00
6fa5674909 Display memory usage reduction (#8)
Convert all string references from const char* to String/F() to store values in flash instead of ram.

Memory usage from `main`:

```
Sketch uses 27878 bytes (90%) of program storage space. Maximum is 30720 bytes.
Global variables use 1755 bytes (85%) of dynamic memory, leaving 293 bytes for local variables. Maximum is 2048 bytes.
```

Memory usage after these changes:
```
Sketch uses 28054 bytes (91%) of program storage space. Maximum is 30720 bytes.
Global variables use 1445 bytes (70%) of dynamic memory, leaving 603 bytes for local variables. Maximum is 2048 bytes.
```

This provides a dynamic memory savings of 310 bytes!

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/8
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-06-22 18:44:01 +00:00
973c13b8ef Add per-channel Swing configuration (#7)
Select swing amount from a percentage range of the beat starting a 50% (unchanged) to a max swing amount of 95% (about 1/32nd note before end of period). Swing percentage shows an indicator marker when the percentage lines up with a quantized note on the grid.

This is probably going to be the last feature because it is pushing up against the limits of available dynamic memory.

Out of scope changes:
- selecting parameters / values no longer wraps
- reduce dynamic memory used in processClockTick
- various readability formatting

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/7
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-06-22 18:38:51 +00:00
c8e42c7448 use appropriate string width method. 2025-06-21 15:45:11 -07:00
54999d6525 Separate display into its own file. 2025-06-17 20:40:51 -07:00
966f5b767b code cleanup for consistency 2025-06-17 07:27:22 -07:00
6c75a85929 fixed type mismatch in default state version. 2025-06-17 06:59:55 -07:00
8a9bf121dc remove unused fields 2025-06-15 21:18:35 -07:00
d12764313b Introduce StateManager to persist state between power cycles (#6)
- add reset state menu option to return all settings back to default values.
- add reverse encoder menu option and save state
- make saving to EEPROM safer by wrapping put calls with noInterrupts()
- improve save state behavior by using a mutex flag and update check with debounce in main loop
- refactor gravity.h global const definitions to be static and more readable.
- improve usage of EncoderDir in ISR with pointer to instance and static isr() method.
- reduce u8g2 memory usage by using single page buffer

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/6
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-06-16 02:47:25 +00:00
07ed4b3d9a Update Font (#5)
Reduce the amount of program memory used by switching to original firmware's optimized fonts.

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/5
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-06-14 21:52:18 +00:00
9bacf43f15 Add per-channel CV Input mod configuration (#4)
Each channel can enable CV 1 or CV 2 as an input source for modulation, which can be applied to any of the user-editable parameters. When editing the parameter, cv mod is not applied in the UI so the user can easily see the base value for editing. When not editing, the UI will display the current cv modded value in the UI for the modded parameter.

I had originally intended to provide configuration for attenuating and offsetting the cv input per channel, but that introduced a significant amount of memory needed to store several new ints per channel. I may return to add this feature later, but given it's something that can easily be done with other modules between the modulation source and Gravity cv input, I am deprioritizing this feature.

Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/4
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-06-14 21:26:33 +00:00
70b9b28032 minor formatting 2025-06-09 22:36:58 -07:00
8aa47b73fd Add new official Gravity firmware code. Split out the output channel behavior and struct into a new class. 2025-06-09 22:33:16 -07:00
6c85b94f21 Refactor handle rotate to make the code more reusable and readable. 2025-06-09 19:54:30 -07:00
dac1bb3007 Big refactor of code for readability and reusability. Mostly focusing on the UI code. 2025-06-08 18:17:19 -07:00
1a13fbff5f Introduce a new demo sketch to visulize the
attenuation and offset constraints of the input
cv.
2025-06-08 11:39:27 -07:00
d9106c6951 refactor calibrate analog demo to use tge u8g2 library. 2025-06-08 11:39:12 -07:00
c1b29924f7 Do not show MIDI tempo. Serial MIDI is too unstable. CV ext seems pretty stable when given a steady clock, but I need to try unstable sources / polyrhythms. 2025-06-03 07:33:50 -07:00
01bf09d4f5 Consistent clock behavior for ext cv and midi. 2025-06-02 21:56:17 -07:00
8cf64fefca Initial commit for midi. Midi out is working, Midi In is still a work in progress. 2025-06-01 22:53:51 -07:00
20f65d9bdf Full rewrite of graphics lib. Replace adafruit with u8g2. Overhaul UI. 2025-06-01 19:18:59 -07:00
edd7df1cd6 Revert pointer change. not worth the few bytes it saved. 2025-05-31 20:28:17 -07:00
18e53e90c1 Fuck it, we're doing pointers for everything! 2025-05-31 17:35:04 -07:00
98c3769008 Update clock.h to support uClock v2.2.1 and implement external PPQN 4 (#3)
Reviewed-on: https://git.pinkduck.xyz/adam/libGravity/pulls/3
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-committed-by: Adam Wonak <adam.wonak@gmail.com>
2025-05-30 03:08:31 +00:00
b580d1e451 Adding various refactoring for optimization and readability. 2025-05-26 11:09:51 -07:00
4446f41957 formatting 2025-05-25 15:31:58 -07:00
b95aa752ca Avoid floating point operations. 2025-05-25 15:31:03 -07:00
3b04196430 switch to using 96ppqn internally to allow more clock modification. 2025-05-25 15:20:48 -07:00
0f69b8501b Update docs 2025-05-25 14:42:39 -07:00
506293fa9c Refactor UI code for analog input calibration script. Display voltage for a more clear matching calibration. 2025-05-25 14:40:38 -07:00
db8c894927 refactor var names and improve docs 2025-05-24 00:30:59 -07:00
392f4fffc7 Add the functionality for calibrating the analog input. Add demo script for calibrating analog input. 2025-05-24 00:26:48 -07:00
7f9ad7e00d basic implementation of analog inputs and test script 2025-05-23 21:36:18 -07:00
9451f987b5 fix long press handler 2025-05-23 17:21:40 -07:00
6762549b4a main process method should not have any logic. 2025-05-23 17:13:15 -07:00
efd569e4df Update encoder to better handle press rotate and use button subclass. 2025-05-23 17:12:31 -07:00
9ed9e01966 refactor button.h to support long press and handle callback functions inside Process(). 2025-05-23 17:11:36 -07:00
b847515f32 Add clock_mod firmware demo. 2025-05-04 22:55:28 -07:00