Save data memory
This commit is contained in:
parent
c6adf3f044
commit
589275a3ba
|
@ -1,5 +1,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#include <pentabug/music.h>
|
#include <pentabug/music.h>
|
||||||
#include <pentabug/hal.h>
|
#include <pentabug/hal.h>
|
||||||
#include <pentabug/helper.h>
|
#include <pentabug/helper.h>
|
||||||
|
@ -7,7 +9,7 @@
|
||||||
|
|
||||||
#define NOTE_BREAK MLDY_LENGTH, 16, NOTE_PAUSE
|
#define NOTE_BREAK MLDY_LENGTH, 16, NOTE_PAUSE
|
||||||
|
|
||||||
static uint16_t notes[] = {
|
static const uint16_t notes[] PROGMEM = {
|
||||||
NOTE_C, NOTE_D, NOTE_E, NOTE_F, MLDY_LENGTH, 2, NOTE_G, MLDY_LENGTH, 2, NOTE_G, NOTE_BREAK,
|
NOTE_C, NOTE_D, NOTE_E, NOTE_F, MLDY_LENGTH, 2, NOTE_G, MLDY_LENGTH, 2, NOTE_G, NOTE_BREAK,
|
||||||
NOTE_A, NOTE_A, NOTE_A, NOTE_A, MLDY_LENGTH, 2, NOTE_G, NOTE_BREAK,
|
NOTE_A, NOTE_A, NOTE_A, NOTE_A, MLDY_LENGTH, 2, NOTE_G, NOTE_BREAK,
|
||||||
NOTE_A, NOTE_A, NOTE_A, NOTE_A, MLDY_LENGTH, 2, NOTE_G, NOTE_BREAK,
|
NOTE_A, NOTE_A, NOTE_A, NOTE_A, MLDY_LENGTH, 2, NOTE_G, NOTE_BREAK,
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
void set_note(uint16_t note, uint8_t octave);
|
void set_note(uint16_t note, uint8_t octave);
|
||||||
|
|
||||||
// plays a melody consisting of the array of tunes of length len with speed ms for each tune
|
// plays a melody consisting of the array of tunes of length len with speed ms for each tune
|
||||||
void play_melody(uint16_t melody[], size_t len, uint8_t octave, int speed);
|
void play_melody(const uint16_t melody[], size_t len, uint8_t octave, int speed);
|
||||||
|
|
||||||
// stop the currently playing note
|
// stop the currently playing note
|
||||||
void stop_note(void);
|
void stop_note(void);
|
||||||
|
|
|
@ -29,7 +29,7 @@ void stop_note(void) {
|
||||||
stop_timer();
|
stop_timer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void play_melody(uint16_t notes[], size_t len, uint8_t octave, int speed) {
|
void play_melody(const uint16_t notes[], size_t len, uint8_t octave, int speed) {
|
||||||
int pause = speed / 20;
|
int pause = speed / 20;
|
||||||
uint8_t length = 4;
|
uint8_t length = 4;
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,16 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#include <pentabug/hal.h>
|
#include <pentabug/hal.h>
|
||||||
#include <pentabug/app.h>
|
#include <pentabug/app.h>
|
||||||
#include <pentabug/lifecycle.h>
|
#include <pentabug/lifecycle.h>
|
||||||
#include <pentabug/music.h>
|
#include <pentabug/music.h>
|
||||||
#include <pentabug/helper.h>
|
#include <pentabug/helper.h>
|
||||||
|
|
||||||
static uint16_t up_mldy[] = { NOTE_C, NOTE_D, MLDY_LENGTH, 2, NOTE_F, NOTE_PAUSE };
|
static const uint16_t up_mldy[] PROGMEM = { NOTE_C, NOTE_D, MLDY_LENGTH, 2, NOTE_F, NOTE_PAUSE };
|
||||||
static uint16_t down_mldy[] = { NOTE_F, NOTE_E, MLDY_LENGTH, 2, NOTE_C, NOTE_PAUSE };
|
static const uint16_t down_mldy[] PROGMEM = { NOTE_F, NOTE_E, MLDY_LENGTH, 2, NOTE_C, NOTE_PAUSE };
|
||||||
|
|
||||||
static inline void run_app(struct app_t* app) {
|
static inline void run_app(struct app_t* app) {
|
||||||
app_should_stop = 0;
|
app_should_stop = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user