Browse Source

use PROGMEM for the pitch-to-period lookup table

master
Peter Cai 1 year ago
parent
commit
149dcf9001
  1. 2
      gen_pitch_table.py
  2. 2
      motor_control.cpp

2
gen_pitch_table.py

@ -44,7 +44,7 @@ print("")
print("constexpr unsigned int midi_pitch_offset = " + str(start_pitch) + ";")
print("constexpr unsigned int midi_pitch_max = " + str(end_pitch) + ";")
print("// period is in units of 0.5 us, instead of 1 us")
print("constexpr unsigned long midi_pitch_period[" + str(end_pitch - start_pitch) + "] = {")
print("constexpr PROGMEM unsigned long midi_pitch_period[" + str(end_pitch - start_pitch) + "] = {")
for i in range(start_pitch, end_pitch):
period = int(2.0 * pitch_to_period_micros(i))

2
motor_control.cpp

@ -77,7 +77,7 @@ void MotorControl::TickAtPitch(unsigned int midi_pitch) {
return;
}
TickOn(midi_pitch_period[midi_pitch - midi_pitch_offset]);
TickOn(pgm_read_dword_near(midi_pitch_period + (midi_pitch - midi_pitch_offset)));
}
void MotorControl::TickPitchBend(int bend) {

Loading…
Cancel
Save