Save data memory

This commit is contained in:
Thammi 2013-08-30 19:57:51 +02:00
parent c6adf3f044
commit 589275a3ba
4 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,7 @@
#include <stdlib.h>
#include <avr/pgmspace.h>
#include <pentabug/music.h>
#include <pentabug/hal.h>
#include <pentabug/helper.h>
@ -7,7 +9,7 @@
#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_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,

View File

@ -25,7 +25,7 @@
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
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
void stop_note(void);

View File

@ -29,7 +29,7 @@ void stop_note(void) {
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;
uint8_t length = 4;

View File

@ -2,14 +2,16 @@
#include <stdint.h>
#include <stdlib.h>
#include <avr/pgmspace.h>
#include <pentabug/hal.h>
#include <pentabug/app.h>
#include <pentabug/lifecycle.h>
#include <pentabug/music.h>
#include <pentabug/helper.h>
static uint16_t up_mldy[] = { 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 up_mldy[] PROGMEM = { NOTE_C, NOTE_D, MLDY_LENGTH, 2, NOTE_F, 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) {
app_should_stop = 0;