added board package source (part 4 libraries)
This commit is contained in:
parent
d571669182
commit
7c8f3f0ddf
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6,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 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 33
|
||||
// setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 3072 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 96 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track2" // ticks = 96 / bytes = 11
|
||||
0x00 + 25, // NOTE ON: note = 25
|
||||
0x52, 0x80 + 2, // FX: SET GLISSANDO: ticks = 2;
|
||||
0x9F + 32, // DELAY: 32 ticks
|
||||
0x52, 0x00 + 2, // FX: SET GLISSANDO: ticks = 2;
|
||||
0x9F + 32, // DELAY: 32 ticks
|
||||
0x53, // FX: GLISSANDO OFF
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 32, // DELAY: 32 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21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3, 0x03, 0x11, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x39, 0x39, 0x39, 0xFF, 0xFF, 0xFF, 0x0F, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xFF, 0x18, 0x38, 0x79, 0xFF, 0xFF, 0xF7, 0x03, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 31
|
||||
// setup bytes 13
|
||||
0x04, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
0x15, 0x00, // Address of track 3
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x01, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 7
|
||||
0x00 + 36, // NOTE ON: note = 36
|
||||
0x47, 0x43, 0x00 + 0x00 + 20, // FX: ARPEGGIO ON: notes = +4 +3 / don't play third note = OFF / ritrigger = OFF / ticks = 20
|
||||
0x9F + 64, // DELAY: 64 ticks
|
||||
0x48, // FX: ARPEGGIO OFF
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0x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, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xFF, 0x18, 0x38, 0x79, 0xFF, 0xFF, 0xF7, 0x03, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 40
|
||||
// setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0xFD, 7, 2, // REPEAT: count = 7 + 1 / track = 2 (8 * 256 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 256 / bytes = 18
|
||||
0x00 + 36, // NOTE ON: note = 36
|
||||
0x47, 0x43, 0x00 + 0x00 + 0, // FX: ARPEGGIO ON: notes = +4 +3 / don't play third note = OFF / ritrigger = OFF / ticks = 0
|
||||
0x9F + 64, // DELAY: ticks = 64
|
||||
0x47, 0x34, 0x00 + 0x00 + 0, // FX: ARPEGGIO ON: notes = +3 +4 / don't play third note = OFF / ritrigger = OFF / ticks = 0
|
||||
0x9F + 64, // DELAY: ticks = 64
|
||||
0x47, 0x25, 0x00 + 0x00 + 0, // FX: ARPEGGIO ON: notes = +2 +5 / don't play third note = OFF / ritrigger = OFF / ticks = 0
|
||||
0x9F + 64, // DELAY: ticks = 64
|
||||
0x47, 0x34, 0x00 + 0x00 + 0, // FX: ARPEGGIO ON: notes = +3 +4 / don't play third note = OFF / ritrigger = OFF / ticks = 0
|
||||
0x9F + 64, // DELAY: ticks = 64
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0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xC3, 0x03, 0x11, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x39, 0x39, 0x39, 0xFF, 0xFF, 0xFF, 0x0F, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xFF, 0x18, 0x38, 0x79, 0xFF, 0xFF, 0xF7, 0x03, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,74 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 78
|
||||
// // setup bytes 17
|
||||
0x06, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
0x20, 0x00, // Address of track 3
|
||||
0x24, 0x00, // Address of track 4
|
||||
0x36, 0x00, // Address of track 5
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x03, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 3072 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 96 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 96 / bytes = 21
|
||||
0x00 + 24, // NOTE ON: note = 24
|
||||
0x9F + 24, // DELAY: 24 ticks
|
||||
0x00 + 36, // NOTE ON: note = 36
|
||||
0x47, 0x43, 0x00 + 0x00 + 0, // FX: ARPEGGIO ON: notes = +4 +3 / don't play third note = OFF / ritrigger = OFF / ticks = 0
|
||||
0x9F + 8, // DELAY: 8 ticks
|
||||
0x00, // NOTE OFF
|
||||
0x48, // FX: ARPEGGIO OFF
|
||||
0x9F + 16, // DELAY: 16 ticks
|
||||
0x00 + 22, // NOTE ON: note = 22
|
||||
0x9F + 24, // DELAY: 24 ticks
|
||||
0x00 + 34, // NOTE ON: note = 34
|
||||
0x47, 0x43, 0x00 + 0x00 + 0, // FX: ARPEGGIO ON: notes = +4 +3 / don't play third note = OFF / ritrigger = OFF / ticks = 0
|
||||
0x9F + 8, // DELAY: 8 ticks
|
||||
0x00, // NOTE OFF
|
||||
0x48, // FX: ARPEGGIO OFF
|
||||
0x9F + 16, // DELAY: 16 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 3072 / bytes = 4
|
||||
0xFD, 31, 4, // REPEAT: count = 31 + 1 / track = 4 (32 * 96 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 4" // ticks = 96 / bytes = 18
|
||||
0xFD, 1, 5, // REPEAT: count = 1 + 1 / track = 5 (24 ticks)
|
||||
0x9F + 12, // DELAY: 12 ticks
|
||||
0xFD, 1, 5, // REPEAT: count = 1 + 1 / track = 5 (24 ticks)
|
||||
0x9F + 12, // DELAY: 12 ticks
|
||||
0x49, 4 + 0, // FX: RETRIG NOISE: point = 1 (*4) / speed = 0 (fastest)
|
||||
0x40, 48, // FX: SET VOLUME: volume = 63
|
||||
0x42, -8, 1, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 24, // DELAY: 24 ticks
|
||||
0x4A, // FX: RETRIG: off
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 5" // ticks = 12 / bytes = 7
|
||||
0x40, 48, // FX: SET VOLUME: volume = 48
|
||||
0x42, -16, 1, // FX: VOLUME SLIDE ON: steps = -16 / every 1 ticks
|
||||
0x9F + 12, // DELAY: 12 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0xC6, 0x07, 0x04, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x87, 0x87, 0x07, 0x07, 0x26, 0x86, 0x07, 0x07, 0xC6, 0xF0,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x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 40
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x01, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 6
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 20
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x9F + 1, // DELAY: ticks = 1
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F + 15, // DELAY: ticks = 15
|
||||
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x9F + 1, // DELAY: ticks = 1
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F + 15, // DELAY: ticks = 15
|
||||
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0xC6, 0x07, 0x04, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x87, 0x87, 0x07,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, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 54
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x01, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 6
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 34
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
|
||||
0x9F + 12, // DELAY: ticks = 12
|
||||
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 50
|
||||
// // setup bytes 15
|
||||
0x05, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
0x13, 0x00, // Address of track 3
|
||||
0x1B, 0x00, // Address of track 4
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x01, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 4096 / bytes = 4
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 128 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 128 / bytes = 10
|
||||
0xFC, 3, // GOTO: track = 3 (32 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 (16 ticks)
|
||||
0xFC, 3, // GOTO: track = 3 (32 ticks)
|
||||
0xFC, 3, // GOTO: track = 3 (32 ticks)
|
||||
0x9F + 16, // DELAY: ticks = 16 (16 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 32 / bytes = 8
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 4" // ticks = 16 / bytes = 8
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 12, // DELAY: ticks = 12
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0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
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x39, 0x39, 0x39, 0xFF, 0xFF, 0xFF, 0x0F, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xFF, 0x18, 0x38, 0x79, 0xFF, 0xFF, 0xF7, 0x03, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 55
|
||||
// // setup bytes 15
|
||||
0x05, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
0x19, 0x00, // Address of track 3
|
||||
0x21, 0x00, // Address of track 4
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x01, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 4
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 4 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 16
|
||||
0xFC, 3, // GOTO: track = 3 ( 8 ticks)
|
||||
0xFD, 2, 4, // REPEAT: count = 2 + 1 / track = 4 (12 ticks)
|
||||
0x9F + 4, // DELAY: ticks = 4 ( 4 ticks)
|
||||
0xFC, 3, // GOTO: track = 3 ( 8 ticks)
|
||||
0xFC, 3, // GOTO: track = 3 ( 8 ticks)
|
||||
0xFC, 3, // GOTO: track = 3 ( 8 ticks)
|
||||
0xFC, 3, // GOTO: track = 3 ( 8 ticks)
|
||||
0x9F + 8, // DELAY: ticks = 8 ( 8 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 8 / bytes = 8
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 4" // ticks = 4 / bytes = 7
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x9F + 2, // DELAY: ticks = 2
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F + 2, // DELAY: ticks = 2
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00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, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 56
|
||||
// // setup bytes 15
|
||||
0x05, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0E, 0x00, // Address of track 2
|
||||
0x1B, 0x00, // Address of track 3
|
||||
0x22, 0x00, // Address of track 4
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x01, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 160 / bytes = 11
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFC, 2, // GOTO: track = 2 (48 ticks)
|
||||
0x9F + 8, // DELAY: ticks = 8 ( 8 ticks)
|
||||
0xFC, 2, // GOTO: track = 2 (48 ticks)
|
||||
0x9F + 8, // DELAY: ticks = 8 ( 8 ticks)
|
||||
0xFC, 2, // GOTO: track = 2 (48 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 48 / bytes = 13
|
||||
0xFD, 5, 3, // REPEAT: count = 5 + 1 / track = 3 (12 ticks)
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F + 4, // DELAY: ticks = 4 ( 4 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 4 ticks)
|
||||
0x9F + 12, // DELAY: ticks = 12 (12 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 4 ticks)
|
||||
0x9F + 12, // DELAY: ticks = 12 (12 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 2 / bytes = 7
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 2, // DELAY: ticks = 2
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 4" // ticks = 4 / bytes = 7
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0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xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 75
|
||||
// // setup bytes 15
|
||||
0x05, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
0x2D, 0x00, // Address of track 3
|
||||
0x34, 0x00, // Address of track 4
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x01, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 64 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 7168 / bytes = 6
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 32 / track = 2 (32 * 224 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 224 / bytes = 36
|
||||
0xFD, 14, 3, // REPEAT: count = 14 + 1 / track = 3 (30 ticks)
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F + 2, // DELAY: ticks = 2 ( 2 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0x9F + 8, // DELAY: ticks = 8 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0x9F + 40, // DELAY: ticks = 40 (40 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0x9F + 8, // DELAY: ticks = 8 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0x9F + 8, // DELAY: ticks = 8 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0x9F + 8, // DELAY: ticks = 8 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0x9F + 8, // DELAY: ticks = 8 ( 8 ticks)
|
||||
0xFC, 4, // GOTO: track = 4 ( 8 ticks)
|
||||
0x9F + 24, // DELAY: ticks = 24 (24 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 2 / bytes = 7
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 2, // DELAY: ticks = 2
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 4" // ticks = 8 / bytes = 8
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0xC6, 0x07, 0x04, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0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 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 55
|
||||
// // setup bytes 17
|
||||
0x06, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
0x10, 0x00, // Address of track 3
|
||||
0x19, 0x00, // Address of track 4
|
||||
0x1D, 0x00, // Address of track 5
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x04, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 6
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 7
|
||||
0xFC, 3, // GOTO: track = 3 ( 4 ticks)
|
||||
0x9F + 12, // DELAY: ticks = 12 (12 ticks)
|
||||
0xFC, 3, // GOTO: track = 3 ( 4 ticks)
|
||||
0x9F + 44, // DELAY: ticks = 44 (44 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 4 / bytes = 9
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x00 + 1, // NOTE ON: note = 1
|
||||
0x41, -16, // FX: VOLUME SLIDE ON: steps = -16
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x00, // NOTE OFF
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 4" // ticks = 2048 / bytes = 4
|
||||
0xFD, 31, 5, // REPEAT: count = 31 + 1 / track = 5 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 5" // ticks = 64 / bytes = 9
|
||||
0x9F + 32, // DELAY: ticks = 32
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0x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, 0x0F, 0xFF, 0xFF, 0x18, 0x38, 0x79, 0xFF, 0xFF, 0xF7, 0x03, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 75
|
||||
// // setup bytes 21
|
||||
0x08, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
0x12, 0x00, // Address of track 3
|
||||
0x1B, 0x00, // Address of track 4
|
||||
0x21, 0x00, // Address of track 5
|
||||
0x27, 0x00, // Address of track 6
|
||||
0x2E, 0x00, // Address of track 7
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x04, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 7
|
||||
0xFC, 3, // GOTO: track = 3 ( 4 ticks)
|
||||
0x9F + 12, // DELAY: ticks = 12 (12 ticks)
|
||||
0xFC, 3, // GOTO: track = 3 ( 4 ticks)
|
||||
0x9F + 44, // DELAY: ticks = 44 (44 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 4 / bytes = 9
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x00 + 1, // NOTE ON: note = 1
|
||||
0x41, -16, // FX: VOLUME SLIDE ON: steps = -16
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x00, // NOTE OFF
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 4" // ticks = 32 * 64 = 2048 / bytes = 6
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0xFD, 31, 5, // REPEAT: count = 31 + 1 / track = 5 (64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 5" // ticks = 64 / bytes = 6
|
||||
0xFD, 5, 7, // REPEAT: count = 6 / track = 7 (48 ticks)
|
||||
0xFC, 6, // GOTO: track = 6 (16 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 6" // ticks = 16 / bytes = 7
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 7" // ticks = 8 / bytes = 8
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -16, // FX: VOLUME SLIDE ON: steps = -16
|
||||
0x9F + 2, // DELAY: ticks = 2
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 6, // DELAY: ticks = 6
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0x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80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 30
|
||||
// setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 6
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 10
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x44, -2, // FX: FREQUENCY SLIDE ON: steps = -2
|
||||
0x9F + 32, // DELAY: ticks = 32
|
||||
0x46, // FX: FREQUENCY SLIDE OFF
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 32, // DELAY: ticks = 32
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0xC6, 0x07, 0x04, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF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x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 33
|
||||
// setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x07, 0x00, // Address of track 2
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 1024 / bytes = 6
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 32 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 32 / bytes = 13
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x00 + 1, // NOTE ON: note = 1
|
||||
0x44, -65, // FX: FREQUENCY SLIDE ON: steps = -65
|
||||
0x41, -16, // FX: VOLUME SLIDE ON: steps = -16
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x46, // FX: FREQUENCY SLIDE OFF
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 28, // DELAY: ticks = 32
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0xC6, 0x07, 0x04, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x87, 0x87, 0x07, 0x07, 0x26, 0x86, 0x07, 0x07, 0xC6, 0xF0, 0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, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = {
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x09, 0x00, // Address of track 1
|
||||
0x0C, 0x00, // Address of track 2
|
||||
|
||||
0x02, // Channel 0 entry track
|
||||
0x01, // Channel 1 entry track
|
||||
0x01, // Channel 2 entry track
|
||||
0x01, // Channel 3 entry track
|
||||
|
||||
//"Track 0"
|
||||
0x00 + 26, // NOTE ON: note = 26
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 30, // NOTE ON: note = 30
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 28, // NOTE ON: note = 28
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 23, // NOTE ON: note = 23
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 1"
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2"
|
||||
0x9D, 25, // SET song tempo: value = 25
|
||||
0x9E, 2, 1, 1, 1, // FX: GOTO advanced: ch0 = 0x02 / ch1 = 0x01 / ch2 = 0x01 / ch3 = 0x01
|
||||
0x40, 48, // FX: SET VOLUME: volume = 48
|
||||
0x41, -4, // FX: VOLUME SLIDE ON: steps = -4
|
||||
0xFC, 0, // GOTO track 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB,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 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 33
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 16, // FX: SET VOLUME: volume = 16
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 11
|
||||
0x00 + 36, // NOTE ON: note = 36
|
||||
0x54, 0, // FX: NOTE CUT: ticks = 0 between switching note ON and note OFF
|
||||
0x9F + 64, // DELAY: 64 ticks
|
||||
0x00 + 39, // NOTE ON: note = 36
|
||||
0x9F + 64, // DELAY: 64 ticks
|
||||
0x00 + 41, // NOTE ON: note = 36
|
||||
0x9F + 64, // DELAY: 64 ticks
|
||||
0x00 + 39, // NOTE ON: note = 36
|
||||
0x9F + 64, // DELAY: 64 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,93 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
const unsigned char PROGMEM TEAMarg[] =
|
||||
{
|
||||
// width, height
|
||||
32, 40,
|
||||
// ######## ########
|
||||
// ########### ## ##
|
||||
// #### ################## ## #### ###
|
||||
// #### ## ################ #################### ############# ###### ## ## # ####
|
||||
// #### ##### ####################### ################## ######## ## ### # #####
|
||||
// #### ## ###### ######## ## ### #### #### ## ## ## ####### # ###
|
||||
// ####### #### # ####### ##### # # ################# ## ### ########## ### ## ### ### ### ### # ### ##########
|
||||
// ##### ########## #### ## # ################# ## ### ############## ## ## ##### # ### ## ## ###
|
||||
// ##### ########### ######## # ################ # ## ################# #### ###### #### ## ########
|
||||
// ##### # ##### ######## ################# # ## ####### ######## #### ######## ###### ### ######## # # ####
|
||||
// # # ###### #################### ################# # ## ####### ####### ## #################### ######## # #
|
||||
// # # # ###### #################### ####### # ## ###### #### ## ## ################# ## ######## # # # #
|
||||
// #### ###### # ################ ############## # ## ####### #### ## # ################# ## ######## ####
|
||||
// #### # ####### # ################# # ############## ### ###### ######### # ###################### ######## # # ####
|
||||
// #### ####### #################### # ############### ### ####### ######## ##################### ######## ####
|
||||
// #### # ###### ######### # ############### ## ###### ######### ###################### ######### # # ####
|
||||
// #### ##### ######## ## ############## ### ###################### ###################### ######### #####
|
||||
// ##### # ##### ######### ### ######## # ###################### ####################### ######## # #####
|
||||
// ##### ### ######## ### ############### ###################### ####################### ######## #####
|
||||
// ###### # ### # ######### #### ################ ####### ######### ######## ############### ######## # # #####
|
||||
// ###### ## # ######## #### ################ ###### ######## ####### ############### ######## #####
|
||||
// ####### # # ### ######### ##### ################# ##### ######## ######## ###### ####### ######## # # ######
|
||||
// ####### # ### ######## #### # ############## ##### ######## ####### ##### ####### ######## ######
|
||||
// ######## # ######## ##### ## ##### #### # ######## ### ### ####### ### ###### ######## # ######
|
||||
// ######## # ##### # ##### #### ##### # #### ## ## ### # ######### ######
|
||||
// # ###### # # # # ######## ##### #### ## # ######## ## ### # ######### # # ### #
|
||||
// # ###### ####### #### ## # ### # #### ######### ### #
|
||||
// ########## # # # # ######### # ## # ### ## ## ## ######### # #######
|
||||
// ######## ## ## # #### ## # ########
|
||||
// ### ####### # ## ###### #### #### ## # # ########
|
||||
// ######### ###### ###### ## # ##################### # ## # ## #### ####### #########
|
||||
// ## ## ###### # ################ ############## ###################### ######
|
||||
// ## ## ## ##### ## ## ######### ############ ####################### #####
|
||||
// ## ## ## ## #### # ## ## ############# #### ##
|
||||
// # ## # ### ## ######## ########## ######### ## ##### ######### ### ##
|
||||
// ## ## ### ##### ########## ########### ########### ###### ##########
|
||||
// ## # ## ############# ############ ############ ########### #### ####### ###
|
||||
// ## ## ### ######## #### ############ ##### ##### ##### #### ## #### ### # #
|
||||
// ## ## # # #### ##### #### ##### #### #### ## ## # # ###
|
||||
// ### ### ## ##### #### ##### ### #### ###### ###
|
||||
// ############ ########## ##### ######
|
||||
// ########### ######## ########
|
||||
// ########### #### ## ##### #### ######## ####
|
||||
// ##### ### # # ## #### # # ######## # #
|
||||
// ##### ### #### ## ### #### ######## ####
|
||||
//
|
||||
//
|
||||
//
|
||||
// part 1
|
||||
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0x3B, 0xFB, 0x93, 0x96, 0xF6, 0xE6, 0xEC, 0xEC, 0xEC, 0xEC, 0xCC, 0x0C, 0x6C, 0xEC, 0xEC, 0xEC, 0xEC, 0x2C, 0x2C,
|
||||
0xFE, 0xF2, 0xF2, 0xFE, 0x02, 0x88, 0x22, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xE1, 0x0D, 0x7D, 0x4D, 0x4D, 0x7D, 0x7D, 0x7D, 0x7D, 0xFD, 0xFD, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE2, 0x88, 0x20, 0x83, 0x1F, 0xFF, 0x8F, 0x83, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0xE0, 0xF8, 0xE0, 0x83, 0x0F, 0x3F, 0xFF, 0xFF, 0x7F, 0x7F, 0xFF,
|
||||
0x4F, 0x49, 0x49, 0x4F, 0x4F, 0x4F, 0xCF, 0xCF, 0x6E, 0x28, 0x62, 0xC8, 0xC2, 0x48, 0x42, 0x48, 0x02, 0x08, 0x03, 0x1E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,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 0x67, 0x61, 0x01, 0x31, 0x79, 0x79,
|
||||
// part 4
|
||||
0x60, 0xC0, 0x60, 0x30, 0x98, 0xCC, 0xE6, 0x73, 0x39, 0x3D, 0x65, 0xE5, 0xFD, 0x01, 0xFF, 0x9E, 0x1C, 0x38, 0xF0, 0xE0, 0xC0, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0xFE, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xE4, 0xE6, 0xFF, 0x3F, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x88, 0x22, 0x88, 0x22, 0x00, 0xFE, 0xF2, 0xF2, 0xFE,
|
||||
0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x20, 0x88, 0x22, 0x08, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xC1, 0x80, 0x80, 0xC0, 0xE0, 0xC3, 0xC3, 0x87, 0x84, 0x0C, 0x0F, 0x00, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x02, 0x48, 0x42, 0x48, 0x4F, 0x4F, 0x4F, 0x49, 0x49, 0x4F,
|
||||
0x3F, 0x0F, 0x0F, 0x0F, 0x07, 0xE3, 0xA7, 0xE7, 0x07, 0x07, 0x0F, 0x0E, 0x0E, 0x1C, 0x1C, 0x19, 0x1B, 0x1F, 0x1F, 0x1F, 0x00, 0x06, 0x06, 0x70, 0x50, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
PROGMEM const unsigned char TEAM_argPart5[] = {
|
||||
// width, height
|
||||
44, 8,
|
||||
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x07, 0x07, 0x07, 0x1F, 0x1F, 0x1F, 0x01, 0x1C, 0x14, 0x15, 0x1D, 0x01, 0x1F, 0x1F, 0x03, 0x07, 0x0F, 0x1F, 0x1F, 0x1E, 0x00, 0x1C, 0x14, 0x15, 0x1D, 0x01, 0x1F, 0x1F, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x01, 0x1D, 0x14, 0x14, 0x1C
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,34 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
// Lower the tempo ever so slightly
|
||||
arduboy.audio.on();
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
for (byte i = 0; i < 4; i++) sprites.drawSelfMasked(32 * i, 10, TEAMarg, i);
|
||||
sprites.drawSelfMasked(43, 50, TEAM_argPart5, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 29
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x05, 0x00, // Address of track 1
|
||||
0x0F, 0x00, // Address of track 2
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 5
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 10
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x54, 0, // FX: NOTE CUT: ticks = 0 between switching note ON and note OFF
|
||||
0xFD, 31, 2, // REPEAT: count = 31 + 1 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 3
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x9F + 64, // DELAY: ticks = 64
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC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x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,94 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 108
|
||||
// // setup bytes 21
|
||||
0x08, // Number of tracks
|
||||
0x00, 0, // Address of track 0
|
||||
0x04, 0, // Address of track 1
|
||||
0x0A, 0, // Address of track 2
|
||||
0x0F, 0, // Address of track 3
|
||||
0x16, 0, // Address of track 4
|
||||
0x2B, 0, // Address of track 5
|
||||
0x39, 0, // Address of track 6
|
||||
0x43, 0, // Address of track 7
|
||||
|
||||
0x02, // Channel 0 entry track (PULSE)
|
||||
0x01, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x03, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 64 / bytes = 4
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F + 64, // DELAY: 64 ticks
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 6
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 3, 4, // REPEAT: count = 3 + 1 / track = 4 (4 * 512 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 2048 / bytes = 5
|
||||
0xFD, 31, 6, // REPEAT: count = 31 + 1 / track = 5 (32 * 64 ticks)
|
||||
0x00, // NOTE OFF
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 3" // ticks = 2048 / bytes = 7
|
||||
0xFD, 7, 0, // REPEAT: count = 7 + 1 / track = 8 (8 *64 ticks)
|
||||
0xFD, 23, 7, // REPEAT: count = 23 + 1 / track = 8 (24 *64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 4" // ticks = 512 / bytes = 21
|
||||
0xFD, 1, 5, // REPEAT: count = 1 + 1 / track = 5 (2 * 64 ticks)
|
||||
0x4B, 3, // FX: ADD TRANSPOSITION: notes = 3
|
||||
0xFD, 1, 5, // REPEAT: count = 1 + 1 / track = 5 (2 * 64 ticks)
|
||||
0x4B, -1, // FX: ADD TRANSPOSITION: notes = 3
|
||||
0xFD, 1, 5, // REPEAT: count = 1 + 1 / track = 5 (2 * 64 ticks)
|
||||
0x4B, 3, // FX: ADD TRANSPOSITION: notes = 3
|
||||
0xFD, 1, 5, // REPEAT: count = 1 + 1 / track = 5 (2 * 64 ticks)
|
||||
0x4B, -5, // FX: ADD TRANSPOSITION: notes = 3
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 5" // ticks = 64 / bytes = 14
|
||||
0x00 + 49, // NOTE ON: note = 49
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x41, -16, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 16, // DELAY: 16 ticks
|
||||
0x40, 16, // FX: SET VOLUME: volume = 16
|
||||
0x41, -4, // FX: VOLUME SLIDE ON: steps = -4
|
||||
0x9F + 4, // DELAY: 4 ticks
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 44, // DELAY: 44 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
//"track 6" // ticks = 64 / bytes = 10
|
||||
0x00 + 13, // NOTE ON: note = 23
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x4E, 1, 0x00 + 0x00 + 30, // SET TREMOLO OR VIBRATO: depth = 16 / retrig = OFF / TorV = TREMOLO / rate = 3
|
||||
0x9F + 62, // DELAY: 62 ticks
|
||||
0x4F, // TREMOLO OR VIBRATO OFF
|
||||
0x9F + 2, // DELAY: 1 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
//"track 7" // ticks = 64 / bytes = 20
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x9F + 1, // DELAY: ticks = 1
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F + 15, // DELAY: ticks = 15
|
||||
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x9F + 1, // DELAY: ticks = 1
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F + 15, // DELAY: ticks = 15
|
||||
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0xC6, 0x07, 0x04, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0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 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,79 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 50
|
||||
// // setup bytes 13
|
||||
0x07, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
0x1C, 0x00, // Address of track 3
|
||||
0x23, 0x00, // Address of track 4
|
||||
0x2A, 0x00, // Address of track 5
|
||||
0x31, 0x00, // Address of track 6
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x01, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 12288 / bytes = 8
|
||||
0x9D, 32, // SET song tempo: value = 32
|
||||
0x40, 48, // FX: SET VOLUME: volume = 48
|
||||
0xFD, 15, 2, // REPEAT: count = 15 + 1 / track = 2 (16 * 768 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 768 / bytes = 18
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9C, 8, // ADD song tempo: value = 2
|
||||
0xFD, 3, 3, // REPEAT: count = 3 + 1 / track = 3 (4 * 48 ticks)
|
||||
0xFD, 3, 4, // REPEAT: count = 3 + 1 / track = 4 (4 * 48 ticks)
|
||||
0xFD, 3, 5, // REPEAT: count = 3 + 1 / track = 5 (4 * 48 ticks)
|
||||
0xFD, 3, 6, // REPEAT: count = 3 + 1 / track = 6 (4 * 48 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 48 / bytes = 7
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 40, // NOTE ON: note = 41
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 44, // NOTE ON: note = 44
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 4" // ticks = 48 / bytes = 7
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 40, // NOTE ON: note = 41
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 45, // NOTE ON: note = 44
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 5" // ticks = 48 / bytes = 7
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 42, // NOTE ON: note = 41
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 46, // NOTE ON: note = 44
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 6" // ticks = 48 / bytes = 7
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 42, // NOTE ON: note = 41
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 47, // NOTE ON: note = 44
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,33 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
// test
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0xC6, 0x07, 0x04, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x87, 0x87, 0x07, 0x07, 0x26, 0x86, 0x07, 0x07, 0xC6, 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x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 37
|
||||
// setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 1216 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0xFD, 18, 2, // REPEAT: count = 18 + 1 / track = 2 (19 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 15
|
||||
0x00 + 1, // NOTE ON: note = 1
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00 + 5, // NOTE ON: note = 5
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00 + 8, // NOTE ON: note = 8
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 44, // DELAY: ticks = 44
|
||||
0x4B, 3, // FX: ADD TRANSPOSITION: notes = 3
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0xFE, 0xE0, 0x0F, 0xFF, 0xF8, 0x80, 0x06, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0F, 0x3F, 0xF0, 0xC6, 0x07, 0x04, 0x04, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x87, 0x87, 0x07, 0x07, 0x26, 0x86, 0x07, 0x07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 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,53 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 64
|
||||
// // setup bytes 13
|
||||
0x04, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x05, 0x00, // Address of track 1
|
||||
0x19, 0x00, // Address of track 2
|
||||
0x22, 0x00, // Address of track 3
|
||||
|
||||
0x02, // Channel 0 entry track (PULSE)
|
||||
0x01, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 5
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 1024 / bytes = 20
|
||||
0xFD, 3, 3, // REPEAT: count = 3 + 1 / track = 3 (4 * 64 ticks)
|
||||
0x4B, 3, // FX: ADD TRANSPOSITION: notes = +3
|
||||
0xFD, 3, 3, // REPEAT: count = 3 + 1 / track = 3 (4 * 64 ticks)
|
||||
0x4B, -1, // FX: ADD TRANSPOSITION: notes = -1
|
||||
0xFD, 3, 3, // REPEAT: count = 3 + 1 / track = 3 (4 * 64 ticks)
|
||||
0x4B, -2, // FX: ADD TRANSPOSITION: notes = -2
|
||||
0xFD, 3, 3, // REPEAT: count = 3 + 1 / track = 3 (4 * 64 ticks)
|
||||
0xFC, 1, // GOTO: track = 1
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 9
|
||||
0x00 + 13, // NOTE ON: note = 13
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x4E, 1, 0x00 + 0x00 + 31, // SET TREMOLO OR VIBRATO: depth = 1 / retrig = OFF / TorV = TREMOLO / rate = 31
|
||||
0x9F + 64, // DELAY: 64 ticks
|
||||
0xFC, 2, // GOTO: track = 2
|
||||
|
||||
//"Track 3" // ticks = 64 / bytes = 12
|
||||
0x00 + 49, // NOTE ON: note = 49
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x41, -16, // FX: VOLUME SLIDE ON: steps = -16
|
||||
0x9F + 16, // DELAY: 16 ticks
|
||||
0x40, 24, // FX: SET VOLUME: volume = 24
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 48, // DELAY: 48 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x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EC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 50
|
||||
// // setup bytes 13
|
||||
0x04, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0B, 0x00, // Address of track 2
|
||||
0x1C, 0x00, // Address of track 3
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 8
|
||||
0x9D, 25, // SET song tempo: value = 25
|
||||
0x40, 48, // FX: SET VOLUME: volume = 48
|
||||
0xFD, 7, 2, // REPEAT: count = 7 + 1 / track = 2 (8 * 256 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 256 / bytes = 17
|
||||
0xFC, 3, // GOTO: track = 3 (64 ticks)
|
||||
0x4C, -5, // FX: SET TRANSPOSITION: notes = -5
|
||||
0xFC, 3, // GOTO: track = 3 (64 ticks)
|
||||
0x4C, -3, // FX: SET TRANSPOSITION: notes = -3
|
||||
0xFC, 3, // GOTO: track = 3 (64 ticks)
|
||||
0x4C, -1, // FX: SET TRANSPOSITION: notes = -1
|
||||
0xFC, 3, // GOTO: track = 3 (64 ticks)
|
||||
0x4C, 0, // FX: SET TRANSPOSITION: notes = 0
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 3" // ticks = 64 / bytes = 9
|
||||
0x41, -4, // FX: VOLUME SLIDE ON: steps = -4
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 41, // NOTE ON: note = 41
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0x00 + 44, // NOTE ON: note = 44
|
||||
0x9F + 16, // DELAY: ticks = 16
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,33 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
// test
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 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 0xFF, 0xFF, 0xFF, 0x39, 0x39, 0x39, 0xFF, 0xFF, 0xFF, 0x0F, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xFF, 0x18, 0x38, 0x79, 0xFF, 0xFF, 0xF7, 0x03, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 30
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0D, 0x00, // Address of track 2
|
||||
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 1024 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0xFD, 31, 2, // REPEAT: count = 32 / track = 2 (32 * 32 ticks)
|
||||
0x4F, // TREMOLO OFF
|
||||
0x00, // NOTE OFF
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track2" // ticks = 32 / bytes = 6
|
||||
0x00 + 25, // NOTE ON: note = 25
|
||||
0x4E, 16, 0x00 + 3, // SET TREMOLO: depth = 16 / retrig = OFF / rate = 3
|
||||
0x9F + 32, // DELAY: 32 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF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F, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,68 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 61
|
||||
// // setup bytes 19
|
||||
0x07, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
0x0D, 0x00, // Address of track 3
|
||||
0x11, 0x00, // Address of track 4
|
||||
0x1E, 0x00, // Address of track 5
|
||||
0x22, 0x00, // Address of track 5
|
||||
|
||||
0x02, // Channel 0 entry track (PULSE)
|
||||
0x01, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 6
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 3, // REPEAT: count = 32 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 2048 / bytes = 4
|
||||
0xFD, 31, 5, // REPEAT: count = 32 / track = 5 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 3" // ticks = 64 / bytes = 4
|
||||
0x00 + 49, // NOTE ON: note = 22
|
||||
0xFC, 4, // GOTO: track = 3 (64 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 4" // ticks = 64 / bytes = 13
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x41, -16, // FX: VOLUME SLIDE ON: steps = -16
|
||||
0x9F + 16, // DELAY: 16 ticks
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x41, -8, // FX: VOLUME SLIDE ON: steps = -8
|
||||
0x9F + 4, // DELAY: 4 ticks
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 43, // DELAY: 44 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
//"Track 5" // ticks = 64 / bytes = 4
|
||||
0x00 + 13, // NOTE ON: note = 23
|
||||
0xFC, 6, // GOTO: track = 3 (64 ticks)
|
||||
0xFE, // RETURN
|
||||
|
||||
//"track 6" // ticks = 64 / bytes = 8
|
||||
0x40, 32, // FX: SET VOLUME: volume = 32
|
||||
0x4E, 1, 0x00 + 30, // SET TREMOLO: depth = 16 / retrig = OFF / rate = 3
|
||||
0x9F + 64, // DELAY: 64 ticks
|
||||
0x4F, // TREMOLO OFF
|
||||
|
||||
0xFE, // RETURN
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB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, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 30
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0D, 0x00, // Address of track 2
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x01, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 1024 / bytes = 8
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0xFD, 31, 2, // REPEAT: count = 32 / track = 2 (32 * 32 ticks)
|
||||
0x4F, // VIBRATO OFF
|
||||
0x00, // NOTE OFF
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track2" // ticks = 32 / bytes = 6
|
||||
0x00 + 37, // NOTE ON: note = 25
|
||||
0x50, 63, 0x00 + 3, // SET VIBRATO: depth = 63 / retrig = OFF / rate = 3
|
||||
0x9F + 32, // DELAY: 32 ticks
|
||||
0xFE, // RETURN
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xF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 0xE5, 0xE5, 0xE4, 0xC4, 0x04, 0x04, 0x04, 0x07, 0x03, 0x00, 0xC0, 0x40, 0xC3, 0x03, 0x11, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x39, 0x39, 0x39, 0xFF, 0xFF, 0xFF, 0x0F, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xFF, 0x18, 0x38, 0x79, 0xFF, 0xFF, 0xF7, 0x03, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 29
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 5
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 4
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 32 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 9
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x40, 63, // FX: SET VOLUME: volume = 63
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 32, // DELAY: ticks = 32
|
||||
0x43, // FX: VOLUME SLIDE OFF
|
||||
0x9F + 32, // DELAY: ticks = 32
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 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FF, 0xFF, 0x0F, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xFF, 0x18, 0x38, 0x79, 0xFF, 0xFF, 0xF7, 0x03, 0xE0, 0xE0, 0xEF, 0xEF, 0x0F, 0xFF, 0xF9, 0xF0, 0xF0, 0xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 29
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x09, 0x00, // Address of track 2
|
||||
|
||||
0x00, // Channel 0 entry track (PULSE)
|
||||
0x01, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 2048 / bytes = 4
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0xFD, 31, 2, // REPEAT: count = 32 / track = 2 (32 * 64 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 64 / bytes = 11
|
||||
0x00 + 41, // NOTE ON: note = 41
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x41, 4, // FX: VOLUME SLIDE ON: steps = 4
|
||||
0x9F + 32, // DELAY: ticks = 32
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x41, -2, // FX: VOLUME SLIDE ON: steps = -2
|
||||
0x9F + 32, // DELAY: ticks = 32
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
#ifndef BITMAPS_H
|
||||
#define BITMAPS_H
|
||||
|
||||
|
||||
///////////////// Menu bitmaps ////////////////////
|
||||
///////////////////////////////////////////////////
|
||||
const unsigned char PROGMEM T_arg[] =
|
||||
{
|
||||
// width, height
|
||||
60, 56,
|
||||
// ######## ######################## #### #
|
||||
// ####### ############## ## ##
|
||||
// ####### ######## ####### ## ####
|
||||
// ###### # ####### ###### # # ####
|
||||
// ###### ## ### ################## ## ## # ##
|
||||
// ###### # #### ## ## # ## #
|
||||
// ###### # #### ## # #######
|
||||
// ##### # ### ## # #####
|
||||
// ##### ## ## ## ######
|
||||
// ##### ########## ## # ## ##
|
||||
// ##### ################ # ## ##
|
||||
// #### # ####### # #####
|
||||
// #### ## ## #####
|
||||
// #### # # #####
|
||||
// #### # # #####
|
||||
// ### # ## # ####
|
||||
// ### ## ## ## ## ####
|
||||
// ### # ## # ####
|
||||
// ### # # ####
|
||||
// ### ################# ################ ####
|
||||
// #### ################ ############### ####
|
||||
// #### ################ ########## #### #####
|
||||
// ##### ############### ############## ######
|
||||
// ##### ############### ###### ### ## ### #
|
||||
// ###### ############# ##### ##### ### #
|
||||
// ###### ############# ############ ### ##
|
||||
// ####### # # ########
|
||||
// ################### # ############ ### ###################
|
||||
// ################### # ############# ###################### #
|
||||
// ########## ### ###### #############
|
||||
// ######### ### #### ###### ###
|
||||
// ######## ## ### ###### # ###
|
||||
// ######## ## ## ## ### ###### ###
|
||||
// ######## ### ## ### ## ####################
|
||||
// ######## ### ## ### ### ### ###########
|
||||
// ######## ## #### ## ###########
|
||||
// ######## ###### ###### #############
|
||||
// ######## # # # # # # ### ####
|
||||
// ######## ### # # ## # # # ########
|
||||
// ######## ### # # ### # # # ########
|
||||
// ######################################################## ##
|
||||
// ################ ## ####### #### ##### # ############ ##
|
||||
// ############# # # # ################
|
||||
// ############# # # # ################
|
||||
// ################ # ######## # ################
|
||||
// #### ######### # ################## # ##### #########
|
||||
// ### # ######## ######################## #### ########
|
||||
// ## ### ######## ###################### ##### ########
|
||||
// # ##### ####### ###################### ###### #########
|
||||
// # #### ####### #################### ### #############
|
||||
// ## ##### ####### #################### ### #############
|
||||
// ####### ## ### ################## ###################
|
||||
// # ### # ### # ### #### #### ###################
|
||||
// ## ### #### #### ######## ####################
|
||||
// ### # ########## ######### ##############################
|
||||
// #### ##################### ## ###########################
|
||||
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFE, 0x0F, 0xE3, 0xFB, 0x1B, 0x0B, 0x0B, 0x8B, 0xFB, 0xF3, 0xF7, 0xF6, 0xF6, 0xF6, 0x06, 0x06, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEE, 0xE6, 0xF6, 0xF6, 0xF6, 0xF7, 0xF3, 0xFB, 0xFB, 0xCB, 0xCB, 0xFB, 0xE3, 0x0F, 0xFE, 0xF8, 0x80, 0x1E, 0x33, 0x21, 0x21, 0x33, 0x9E,
|
||||
0x00, 0x00, 0x00, 0x80, 0xF8, 0xFF, 0x0F, 0xE0, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF1, 0xF3, 0xF3, 0xF3, 0xF3, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0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xFC, 0xFD, 0xFD, 0xFD, 0x0D, 0xEC, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x01, 0x21, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xC0, 0x60, 0x20, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x7E, 0xFE, 0x80, 0x3C, 0x3E, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0C, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1E, 0x1C, 0x1C, 0x1C, 0x1C, 0x3C, 0x3E, 0x80, 0xFE, 0x7E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00,
|
||||
0x0E, 0x1B, 0x31, 0x66, 0xC6, 0x80, 0xD0, 0x60, 0x31, 0x1B, 0x0E, 0x00, 0x00, 0x38, 0x28, 0x38, 0x00, 0x01, 0x47, 0x1E, 0x38, 0x20, 0x20, 0x20, 0x20, 0x30, 0x10, 0x10, 0xD0, 0xD0, 0x10, 0x10, 0x90, 0x10, 0x30, 0x20, 0x20, 0x20, 0x20, 0x38, 0x1E, 0x07, 0x01, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef SONG_H
|
||||
#define SONG_H
|
||||
|
||||
#define Song const uint8_t PROGMEM
|
||||
|
||||
Song music[] = { // total song in bytes = 38
|
||||
// // setup bytes 11
|
||||
0x03, // Number of tracks
|
||||
0x00, 0x00, // Address of track 0
|
||||
0x03, 0x00, // Address of track 1
|
||||
0x0E, 0x00, // Address of track 2
|
||||
|
||||
0x01, // Channel 0 entry track (PULSE)
|
||||
0x00, // Channel 1 entry track (SQUARE)
|
||||
0x00, // Channel 2 entry track (TRIANGLE)
|
||||
0x00, // Channel 3 entry track (NOISE)
|
||||
|
||||
//"Track 0" // ticks = 0 / bytes = 3
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 1" // ticks = 768 / bytes = 11
|
||||
0x9D, 50, // SET song tempo: value = 50
|
||||
0x40, 0, // FX: SET VOLUME: volume = 0
|
||||
0x42, 2, 24, // FX: VOLUME SLIDE advanced: steps = 2 / every ticks = 24
|
||||
0xFD, 31, 2, // REPEAT: count = 32 / track = 2 (32 * 24 ticks)
|
||||
0x9F, // FX: STOP CURRENT CHANNEL
|
||||
|
||||
//"Track 2" // ticks = 24 / bytes = 13
|
||||
0x00 + 37, // NOTE ON: note = 37
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00 + 41, // NOTE ON: note = 41
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00 + 44, // NOTE ON: note = 44
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0x00, // NOTE OFF
|
||||
0x9F + 4, // DELAY: ticks = 4
|
||||
0xFE, // RETURN
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#include <Arduino.h>
|
||||
#include <Arduboy2.h>
|
||||
#include <ATMlib.h>
|
||||
#include "bitmaps.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
Arduboy2Base arduboy;
|
||||
Sprites sprites;
|
||||
ATMsynth ATM;
|
||||
|
||||
void setup() {
|
||||
arduboy.begin();
|
||||
// set the framerate of the game at 60 fps
|
||||
arduboy.setFrameRate(60);
|
||||
// let's make sure the sound was not muted in a previous sketch
|
||||
arduboy.audio.on();
|
||||
// Initializes ATMSynth and samplerate
|
||||
// Begin playback of song.
|
||||
ATM.play(music);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (!(arduboy.nextFrame())) return;
|
||||
arduboy.pollButtons();
|
||||
arduboy.clear();
|
||||
sprites.drawSelfMasked(34, 4, T_arg, 0);
|
||||
if (arduboy.justPressed(B_BUTTON)) ATM.playPause();
|
||||
if (arduboy.justPressed(A_BUTTON)) ATM.playPause();
|
||||
arduboy.display();
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
So our tracker player should have:
|
||||
|
||||
song = how much channels are used, speed, repeat song at position x (0 = no repeat), order of patterns to be played
|
||||
pattern = length of the pattern?,instrument, note, volume?, effect, (every channel has it's own pattern. In a classic mod, all channels are included in the same pattern)
|
||||
instrument = or the sample, or the synth instrument (with an optional indication of which portion of the sample can be repeated to hold a sustained note)
|
||||
|
||||
We need people who can actually help creating such a player.
|
||||
```
|
||||
|
||||
Song ={3, 64, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4}
|
||||
|
||||
patterns channel1 = { pattern1ch1, pattern2ch1, pattern3ch1, pattern4ch1}
|
||||
patterns channel2 = { pattern1ch2, pattern2ch2, pattern3ch2, pattern4ch2}
|
||||
patterns channel3 = { pattern1ch3, pattern2ch3, pattern3ch3, pattern4ch3}
|
||||
|
||||
pattern1ch1[64] = {5448, 5801, 3d16, 0024, 0000, 404b, 1400, 0c00, ...}
|
||||
pattern1ch2[0] = {}
|
||||
pattern1ch2[4] = {2c00, 3600, 2600, 3500, ..}
|
||||
|
||||
instrument 1 = ..
|
||||
instrument 2 = ..
|
||||
instrument 3 = ..
|
||||
instrument 4 = ..
|
||||
instrument 5 = ..
|
||||
```
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
### FREQUENCY TONE DESCRIPTION
|
||||
|
||||
| nr | Tone |Freq| | nr | Tone |Freq| | nr | Tone |Freq|
|
||||
| --- | --- | ---|---| --- | --- | ---|---| --- | --- | ---|
|
||||
|**0** | off |0 | | | | | | | | |
|
||||
|**1** | C4 |262 | |**13**| C5 |523 | |**25**| C6 |1047|
|
||||
|**2** | C#4 |277 | |**14**| C#5 |554 | |**26**| C#6 |1109|
|
||||
|**3** | D4 |294 | |**15**| D5 |587 | |**27**| D6 |1175|
|
||||
|**4** | D#4 |311 | |**16**| D#5 |622 | |**28**| D#6 |1245|
|
||||
|**5** | E4 |330 | |**17**| E5 |659 | |**29**| E6 |1319|
|
||||
|**6** | F4 |349 | |**18**| F5 |698 | |**30**| F6 |1397|
|
||||
|**7** | F#4 |370 | |**19**| F#5 |740 | |**31**| F#6 |1480|
|
||||
|**8** | G4 |392 | |**20**| G5 |784 | |**32**| G6 |1568|
|
||||
|**9** | G#4 |415 | |**21**| G#5 |831 | |**33**| G#6 |1661|
|
||||
|**10**| A4 |440 | |**22**| A5 |880 | |**34**| A6 |1760|
|
||||
|**11**| A#4 |466 | |**23**| A#5 |932 | |**35**| A#6 |1865|
|
||||
|**12**| B4 |494 | |**24**| B5 |988 | |**36**| B6 |1976|
|
||||
|
||||
| nr | Tone |Freq| | nr | Tone |Freq| | nr | Tone |Freq|
|
||||
| --- | --- | ---|---| --- | --- | ---|---| --- | --- |--- |
|
||||
|**37**| C7 |2093| |**49**| C8 |4186| |**61**| C9 |8372|
|
||||
|**38**| C#7 |2217| |**50**| C#8 |4435| |**62**| C#9 |8870|
|
||||
|**39**| D7 |2349| |**51**| D8 |4699| |**63**| D9 |9397|
|
||||
|**40**| D#7 |2489| |**52**| D#8 |4978| | | | |
|
||||
|**41**| E7 |2637| |**53**| E8 |5274| | | | |
|
||||
|**42**| F7 |2794| |**54**| F8 |5588| | | | |
|
||||
|**43**| F#7 |2960| |**55**| F#8 |5920| | | | |
|
||||
|**44**| G7 |3136| |**56**| G8 |6272| | | | |
|
||||
|**45**| G#7 |3322| |**57**| G#8 |6645| | | | |
|
||||
|**46**| A7 |3520| |**58**| A8 |7040| | | | |
|
||||
|**47**| A#7 |3729| |**59**| A#8 |7459| | | | |
|
||||
|**48**| B7 |3951| |**60**| B8 |7902| | | | |
|
|
@ -0,0 +1,19 @@
|
|||
### NOTES IN CHORDS
|
||||
|
||||
| chord | Major | next nrs | ATM parameter | Minor | next nrs | ATM parameter |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| C | C,E,G | + 4 + 3 | 0x43 or 67 | C,D#,G | + 3 + 4 | 0x34 or 52 |
|
||||
| C# | C#,F,G# | + 4 + 3 | 0x43 or 67 | C#,E,G# | + 3 + 4 | 0x34 or 52 |
|
||||
| D | D,F#,A | + 4 + 3 | 0x43 or 67 | D,F,A | + 3 + 4 | 0x34 or 52 |
|
||||
| D# | D#,G,A# | + 4 + 3 | 0x43 or 67 | D#,F#,A# | + 3 + 4 | 0x34 or 52 |
|
||||
| E | E,G#,B | + 4 + 3 | 0x43 or 67 | E,G,B | + 3 + 4 | 0x34 or 52 |
|
||||
| F | F,A,C | + 4 + 3 | 0x43 or 67 | F,G#,C | + 3 + 4 | 0x34 or 52 |
|
||||
| F# | F#,A#,C# | + 4 + 3 | 0x43 or 67 | F#,A,C# | + 3 + 4 | 0x34 or 52 |
|
||||
| G | G,B,D | + 4 + 3 | 0x43 or 67 | G,A#,D | + 3 + 4 | 0x34 or 52 |
|
||||
| G# | G#,C,D# | + 4 + 3 | 0x43 or 67 | G#,B,D# | + 3 + 4 | 0x34 or 52 |
|
||||
| A | A,C#,E | + 4 + 3 | 0x43 or 67 | A,C,E | + 3 + 4 | 0x34 or 52 |
|
||||
| A# | A#,D,F | + 4 + 3 | 0x43 or 67 | A#,C#,F | + 3 + 4 | 0x34 or 52 |
|
||||
| B | B,D#,F# | + 4 + 3 | 0x43 or 67 | B,D,F# | + 3 + 4 | 0x34 or 52 |
|
||||
|
||||
|
||||
Major chord - made up of the 1,3, and 5 note in that keys scale. Minor chord - flat the 3rd note of the scale
|
|
@ -0,0 +1,20 @@
|
|||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
ATMsynth KEYWORD1
|
||||
Oscillator KEYWORD1
|
||||
Melody KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
play KEYWORD2
|
||||
playPause KEYWORD2
|
||||
stop KEYWORD2
|
||||
toggleMute KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Instances (KEYWORD2)
|
||||
#######################################
|
||||
osc KEYWORD2
|
||||
pcm KEYWORD2
|
|
@ -0,0 +1,84 @@
|
|||
// I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
// and James Tichenor <http://www.jamestichenor.net>
|
||||
|
||||
// Demonstrates use of the Wire library reading data from the
|
||||
// Devantech Utrasonic Rangers SFR08 and SFR10
|
||||
|
||||
// Created 29 April 2006
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Wire.begin(); // join i2c bus (address optional for master)
|
||||
Serial.begin(9600); // start serial communication at 9600bps
|
||||
}
|
||||
|
||||
int reading = 0;
|
||||
|
||||
void loop() {
|
||||
// step 1: instruct sensor to read echoes
|
||||
Wire.beginTransmission(112); // transmit to device #112 (0x70)
|
||||
// the address specified in the datasheet is 224 (0xE0)
|
||||
// but i2c adressing uses the high 7 bits so it's 112
|
||||
Wire.write(byte(0x00)); // sets register pointer to the command register (0x00)
|
||||
Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50)
|
||||
// use 0x51 for centimeters
|
||||
// use 0x52 for ping microseconds
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
|
||||
// step 2: wait for readings to happen
|
||||
delay(70); // datasheet suggests at least 65 milliseconds
|
||||
|
||||
// step 3: instruct sensor to return a particular echo reading
|
||||
Wire.beginTransmission(112); // transmit to device #112
|
||||
Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02)
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
|
||||
// step 4: request reading from sensor
|
||||
Wire.requestFrom(112, 2); // request 2 bytes from slave device #112
|
||||
|
||||
// step 5: receive reading from sensor
|
||||
if (2 <= Wire.available()) { // if two bytes were received
|
||||
reading = Wire.read(); // receive high byte (overwrites previous reading)
|
||||
reading = reading << 8; // shift high byte to be high 8 bits
|
||||
reading |= Wire.read(); // receive low byte as lower 8 bits
|
||||
Serial.println(reading); // print the reading
|
||||
}
|
||||
|
||||
delay(250); // wait a bit since people have to read the output :)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
// The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08)
|
||||
// usage: changeAddress(0x70, 0xE6);
|
||||
|
||||
void changeAddress(byte oldAddress, byte newAddress)
|
||||
{
|
||||
Wire.beginTransmission(oldAddress);
|
||||
Wire.write(byte(0x00));
|
||||
Wire.write(byte(0xA0));
|
||||
Wire.endTransmission();
|
||||
|
||||
Wire.beginTransmission(oldAddress);
|
||||
Wire.write(byte(0x00));
|
||||
Wire.write(byte(0xAA));
|
||||
Wire.endTransmission();
|
||||
|
||||
Wire.beginTransmission(oldAddress);
|
||||
Wire.write(byte(0x00));
|
||||
Wire.write(byte(0xA5));
|
||||
Wire.endTransmission();
|
||||
|
||||
Wire.beginTransmission(oldAddress);
|
||||
Wire.write(byte(0x00));
|
||||
Wire.write(newAddress);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
*/
|
|
@ -0,0 +1,36 @@
|
|||
// I2C Digital Potentiometer
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
// and Shawn Bonkowski <http://people.interaction-ivrea.it/s.bonkowski/>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Controls AD5171 digital potentiometer via I2C/TWI
|
||||
|
||||
// Created 31 March 2006
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Wire.begin(); // join i2c bus (address optional for master)
|
||||
}
|
||||
|
||||
byte val = 0;
|
||||
|
||||
void loop() {
|
||||
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
|
||||
// device address is specified in datasheet
|
||||
Wire.write(byte(0x00)); // sends instruction byte
|
||||
Wire.write(val); // sends potentiometer value byte
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
|
||||
val++; // increment value
|
||||
if (val == 64) { // if reached 64th position (max)
|
||||
val = 0; // start over from lowest value
|
||||
}
|
||||
delay(500);
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// Wire Master Reader
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Reads data from an I2C/TWI slave device
|
||||
// Refer to the "Wire Slave Sender" example for use with this
|
||||
|
||||
// Created 29 March 2006
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Wire.begin(); // join i2c bus (address optional for master)
|
||||
Serial.begin(9600); // start serial for output
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Wire.requestFrom(8, 6); // request 6 bytes from slave device #8
|
||||
|
||||
while (Wire.available()) { // slave may send less than requested
|
||||
char c = Wire.read(); // receive a byte as character
|
||||
Serial.print(c); // print the character
|
||||
}
|
||||
|
||||
delay(500);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// Wire Master Writer
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Writes data to an I2C/TWI slave device
|
||||
// Refer to the "Wire Slave Receiver" example for use with this
|
||||
|
||||
// Created 29 March 2006
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Wire.begin(); // join i2c bus (address optional for master)
|
||||
}
|
||||
|
||||
byte x = 0;
|
||||
|
||||
void loop() {
|
||||
Wire.beginTransmission(8); // transmit to device #8
|
||||
Wire.write("x is "); // sends five bytes
|
||||
Wire.write(x); // sends one byte
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
|
||||
x++;
|
||||
delay(500);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// Wire Slave Receiver
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Receives data as an I2C/TWI slave device
|
||||
// Refer to the "Wire Master Writer" example for use with this
|
||||
|
||||
// Created 29 March 2006
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Wire.begin(8); // join i2c bus with address #8
|
||||
Wire.onReceive(receiveEvent); // register event
|
||||
Serial.begin(9600); // start serial for output
|
||||
}
|
||||
|
||||
void loop() {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// function that executes whenever data is received from master
|
||||
// this function is registered as an event, see setup()
|
||||
void receiveEvent(int howMany) {
|
||||
while (1 < Wire.available()) { // loop through all but the last
|
||||
char c = Wire.read(); // receive byte as a character
|
||||
Serial.print(c); // print the character
|
||||
}
|
||||
int x = Wire.read(); // receive byte as an integer
|
||||
Serial.println(x); // print the integer
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// Wire Slave Sender
|
||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
||||
|
||||
// Demonstrates use of the Wire library
|
||||
// Sends data as an I2C/TWI slave device
|
||||
// Refer to the "Wire Master Reader" example for use with this
|
||||
|
||||
// Created 29 March 2006
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Wire.begin(8); // join i2c bus with address #8
|
||||
Wire.onRequest(requestEvent); // register event
|
||||
}
|
||||
|
||||
void loop() {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// function that executes whenever data is requested by master
|
||||
// this function is registered as an event, see setup()
|
||||
void requestEvent() {
|
||||
Wire.write("hello "); // respond with message of 6 bytes
|
||||
// as expected by master
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#######################################
|
||||
# Syntax Coloring Map For Wire
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
begin KEYWORD2
|
||||
setClock KEYWORD2
|
||||
beginTransmission KEYWORD2
|
||||
endTransmission KEYWORD2
|
||||
requestFrom KEYWORD2
|
||||
onReceive KEYWORD2
|
||||
onRequest KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Instances (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
Wire KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
name=Wire
|
||||
version=1.0
|
||||
author=Arduino
|
||||
maintainer=Arduino <info@arduino.cc>
|
||||
sentence=This library allows you to communicate with I2C and Two Wire Interface devices.
|
||||
paragraph=It allows the communication with I2C devices like temperature sensors, realtime clocks and many others using SDA (Data Line) and SCL (Clock Line).
|
||||
category=Communication
|
||||
url=http://www.arduino.cc/en/Reference/Wire
|
||||
architectures=avr
|
||||
|
|
@ -0,0 +1,330 @@
|
|||
/*
|
||||
TwoWire.cpp - TWI/I2C library for Wiring & Arduino
|
||||
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "utility/twi.h"
|
||||
}
|
||||
|
||||
#include "Wire.h"
|
||||
|
||||
// Initialize Class Variables //////////////////////////////////////////////////
|
||||
|
||||
uint8_t TwoWire::rxBuffer[BUFFER_LENGTH];
|
||||
uint8_t TwoWire::rxBufferIndex = 0;
|
||||
uint8_t TwoWire::rxBufferLength = 0;
|
||||
|
||||
uint8_t TwoWire::txAddress = 0;
|
||||
uint8_t TwoWire::txBuffer[BUFFER_LENGTH];
|
||||
uint8_t TwoWire::txBufferIndex = 0;
|
||||
uint8_t TwoWire::txBufferLength = 0;
|
||||
|
||||
uint8_t TwoWire::transmitting = 0;
|
||||
void (*TwoWire::user_onRequest)(void);
|
||||
void (*TwoWire::user_onReceive)(int);
|
||||
|
||||
// Constructors ////////////////////////////////////////////////////////////////
|
||||
|
||||
TwoWire::TwoWire()
|
||||
{
|
||||
}
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
|
||||
void TwoWire::begin(void)
|
||||
{
|
||||
rxBufferIndex = 0;
|
||||
rxBufferLength = 0;
|
||||
|
||||
txBufferIndex = 0;
|
||||
txBufferLength = 0;
|
||||
|
||||
twi_init();
|
||||
}
|
||||
|
||||
void TwoWire::begin(uint8_t address)
|
||||
{
|
||||
twi_setAddress(address);
|
||||
twi_attachSlaveTxEvent(onRequestService);
|
||||
twi_attachSlaveRxEvent(onReceiveService);
|
||||
begin();
|
||||
}
|
||||
|
||||
void TwoWire::begin(int address)
|
||||
{
|
||||
begin((uint8_t)address);
|
||||
}
|
||||
|
||||
void TwoWire::end(void)
|
||||
{
|
||||
twi_disable();
|
||||
}
|
||||
|
||||
void TwoWire::setClock(uint32_t clock)
|
||||
{
|
||||
twi_setFrequency(clock);
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddress, uint8_t isize, uint8_t sendStop)
|
||||
{
|
||||
if (isize > 0) {
|
||||
// send internal address; this mode allows sending a repeated start to access
|
||||
// some devices' internal registers. This function is executed by the hardware
|
||||
// TWI module on other processors (for example Due's TWI_IADR and TWI_MMR registers)
|
||||
|
||||
beginTransmission(address);
|
||||
|
||||
// the maximum size of internal address is 3 bytes
|
||||
if (isize > 3){
|
||||
isize = 3;
|
||||
}
|
||||
|
||||
// write internal register address - most significant byte first
|
||||
while (isize-- > 0)
|
||||
write((uint8_t)(iaddress >> (isize*8)));
|
||||
endTransmission(false);
|
||||
}
|
||||
|
||||
// clamp to buffer length
|
||||
if(quantity > BUFFER_LENGTH){
|
||||
quantity = BUFFER_LENGTH;
|
||||
}
|
||||
// perform blocking read into buffer
|
||||
uint8_t read = twi_readFrom(address, rxBuffer, quantity, sendStop);
|
||||
// set rx buffer iterator vars
|
||||
rxBufferIndex = 0;
|
||||
rxBufferLength = read;
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop) {
|
||||
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint32_t)0, (uint8_t)0, (uint8_t)sendStop);
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)
|
||||
{
|
||||
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(int address, int quantity)
|
||||
{
|
||||
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
|
||||
}
|
||||
|
||||
uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)
|
||||
{
|
||||
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
|
||||
}
|
||||
|
||||
void TwoWire::beginTransmission(uint8_t address)
|
||||
{
|
||||
// indicate that we are transmitting
|
||||
transmitting = 1;
|
||||
// set address of targeted slave
|
||||
txAddress = address;
|
||||
// reset tx buffer iterator vars
|
||||
txBufferIndex = 0;
|
||||
txBufferLength = 0;
|
||||
}
|
||||
|
||||
void TwoWire::beginTransmission(int address)
|
||||
{
|
||||
beginTransmission((uint8_t)address);
|
||||
}
|
||||
|
||||
//
|
||||
// Originally, 'endTransmission' was an f(void) function.
|
||||
// It has been modified to take one parameter indicating
|
||||
// whether or not a STOP should be performed on the bus.
|
||||
// Calling endTransmission(false) allows a sketch to
|
||||
// perform a repeated start.
|
||||
//
|
||||
// WARNING: Nothing in the library keeps track of whether
|
||||
// the bus tenure has been properly ended with a STOP. It
|
||||
// is very possible to leave the bus in a hung state if
|
||||
// no call to endTransmission(true) is made. Some I2C
|
||||
// devices will behave oddly if they do not see a STOP.
|
||||
//
|
||||
uint8_t TwoWire::endTransmission(uint8_t sendStop)
|
||||
{
|
||||
// transmit buffer (blocking)
|
||||
uint8_t ret = twi_writeTo(txAddress, txBuffer, txBufferLength, 1, sendStop);
|
||||
// reset tx buffer iterator vars
|
||||
txBufferIndex = 0;
|
||||
txBufferLength = 0;
|
||||
// indicate that we are done transmitting
|
||||
transmitting = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// This provides backwards compatibility with the original
|
||||
// definition, and expected behaviour, of endTransmission
|
||||
//
|
||||
uint8_t TwoWire::endTransmission(void)
|
||||
{
|
||||
return endTransmission(true);
|
||||
}
|
||||
|
||||
// must be called in:
|
||||
// slave tx event callback
|
||||
// or after beginTransmission(address)
|
||||
size_t TwoWire::write(uint8_t data)
|
||||
{
|
||||
if(transmitting){
|
||||
// in master transmitter mode
|
||||
// don't bother if buffer is full
|
||||
if(txBufferLength >= BUFFER_LENGTH){
|
||||
setWriteError();
|
||||
return 0;
|
||||
}
|
||||
// put byte in tx buffer
|
||||
txBuffer[txBufferIndex] = data;
|
||||
++txBufferIndex;
|
||||
// update amount in buffer
|
||||
txBufferLength = txBufferIndex;
|
||||
}else{
|
||||
// in slave send mode
|
||||
// reply to master
|
||||
twi_transmit(&data, 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// must be called in:
|
||||
// slave tx event callback
|
||||
// or after beginTransmission(address)
|
||||
size_t TwoWire::write(const uint8_t *data, size_t quantity)
|
||||
{
|
||||
if(transmitting){
|
||||
// in master transmitter mode
|
||||
for(size_t i = 0; i < quantity; ++i){
|
||||
write(data[i]);
|
||||
}
|
||||
}else{
|
||||
// in slave send mode
|
||||
// reply to master
|
||||
twi_transmit(data, quantity);
|
||||
}
|
||||
return quantity;
|
||||
}
|
||||
|
||||
// must be called in:
|
||||
// slave rx event callback
|
||||
// or after requestFrom(address, numBytes)
|
||||
int TwoWire::available(void)
|
||||
{
|
||||
return rxBufferLength - rxBufferIndex;
|
||||
}
|
||||
|
||||
// must be called in:
|
||||
// slave rx event callback
|
||||
// or after requestFrom(address, numBytes)
|
||||
int TwoWire::read(void)
|
||||
{
|
||||
int value = -1;
|
||||
|
||||
// get each successive byte on each call
|
||||
if(rxBufferIndex < rxBufferLength){
|
||||
value = rxBuffer[rxBufferIndex];
|
||||
++rxBufferIndex;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// must be called in:
|
||||
// slave rx event callback
|
||||
// or after requestFrom(address, numBytes)
|
||||
int TwoWire::peek(void)
|
||||
{
|
||||
int value = -1;
|
||||
|
||||
if(rxBufferIndex < rxBufferLength){
|
||||
value = rxBuffer[rxBufferIndex];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void TwoWire::flush(void)
|
||||
{
|
||||
// XXX: to be implemented.
|
||||
}
|
||||
|
||||
// behind the scenes function that is called when data is received
|
||||
void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes)
|
||||
{
|
||||
// don't bother if user hasn't registered a callback
|
||||
if(!user_onReceive){
|
||||
return;
|
||||
}
|
||||
// don't bother if rx buffer is in use by a master requestFrom() op
|
||||
// i know this drops data, but it allows for slight stupidity
|
||||
// meaning, they may not have read all the master requestFrom() data yet
|
||||
if(rxBufferIndex < rxBufferLength){
|
||||
return;
|
||||
}
|
||||
// copy twi rx buffer into local read buffer
|
||||
// this enables new reads to happen in parallel
|
||||
for(uint8_t i = 0; i < numBytes; ++i){
|
||||
rxBuffer[i] = inBytes[i];
|
||||
}
|
||||
// set rx iterator vars
|
||||
rxBufferIndex = 0;
|
||||
rxBufferLength = numBytes;
|
||||
// alert user program
|
||||
user_onReceive(numBytes);
|
||||
}
|
||||
|
||||
// behind the scenes function that is called when data is requested
|
||||
void TwoWire::onRequestService(void)
|
||||
{
|
||||
// don't bother if user hasn't registered a callback
|
||||
if(!user_onRequest){
|
||||
return;
|
||||
}
|
||||
// reset tx buffer iterator vars
|
||||
// !!! this will kill any pending pre-master sendTo() activity
|
||||
txBufferIndex = 0;
|
||||
txBufferLength = 0;
|
||||
// alert user program
|
||||
user_onRequest();
|
||||
}
|
||||
|
||||
// sets function called on slave write
|
||||
void TwoWire::onReceive( void (*function)(int) )
|
||||
{
|
||||
user_onReceive = function;
|
||||
}
|
||||
|
||||
// sets function called on slave read
|
||||
void TwoWire::onRequest( void (*function)(void) )
|
||||
{
|
||||
user_onRequest = function;
|
||||
}
|
||||
|
||||
// Preinstantiate Objects //////////////////////////////////////////////////////
|
||||
|
||||
TwoWire Wire = TwoWire();
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
TwoWire.h - TWI/I2C library for Arduino & Wiring
|
||||
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
|
||||
*/
|
||||
|
||||
#ifndef TwoWire_h
|
||||
#define TwoWire_h
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "Stream.h"
|
||||
|
||||
#define BUFFER_LENGTH 32
|
||||
|
||||
// WIRE_HAS_END means Wire has end()
|
||||
#define WIRE_HAS_END 1
|
||||
|
||||
class TwoWire : public Stream
|
||||
{
|
||||
private:
|
||||
static uint8_t rxBuffer[];
|
||||
static uint8_t rxBufferIndex;
|
||||
static uint8_t rxBufferLength;
|
||||
|
||||
static uint8_t txAddress;
|
||||
static uint8_t txBuffer[];
|
||||
static uint8_t txBufferIndex;
|
||||
static uint8_t txBufferLength;
|
||||
|
||||
static uint8_t transmitting;
|
||||
static void (*user_onRequest)(void);
|
||||
static void (*user_onReceive)(int);
|
||||
static void onRequestService(void);
|
||||
static void onReceiveService(uint8_t*, int);
|
||||
public:
|
||||
TwoWire();
|
||||
void begin();
|
||||
void begin(uint8_t);
|
||||
void begin(int);
|
||||
void end();
|
||||
void setClock(uint32_t);
|
||||
void beginTransmission(uint8_t);
|
||||
void beginTransmission(int);
|
||||
uint8_t endTransmission(void);
|
||||
uint8_t endTransmission(uint8_t);
|
||||
uint8_t requestFrom(uint8_t, uint8_t);
|
||||
uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
|
||||
uint8_t requestFrom(uint8_t, uint8_t, uint32_t, uint8_t, uint8_t);
|
||||
uint8_t requestFrom(int, int);
|
||||
uint8_t requestFrom(int, int, int);
|
||||
virtual size_t write(uint8_t);
|
||||
virtual size_t write(const uint8_t *, size_t);
|
||||
virtual int available(void);
|
||||
virtual int read(void);
|
||||
virtual int peek(void);
|
||||
virtual void flush(void);
|
||||
void onReceive( void (*)(int) );
|
||||
void onRequest( void (*)(void) );
|
||||
|
||||
inline size_t write(unsigned long n) { return write((uint8_t)n); }
|
||||
inline size_t write(long n) { return write((uint8_t)n); }
|
||||
inline size_t write(unsigned int n) { return write((uint8_t)n); }
|
||||
inline size_t write(int n) { return write((uint8_t)n); }
|
||||
using Print::write;
|
||||
};
|
||||
|
||||
extern TwoWire Wire;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,561 @@
|
|||
/*
|
||||
twi.c - TWI/I2C library for Wiring & Arduino
|
||||
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <compat/twi.h>
|
||||
#include "Arduino.h" // for digitalWrite
|
||||
|
||||
#ifndef cbi
|
||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||
#endif
|
||||
|
||||
#ifndef sbi
|
||||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
#include "pins_arduino.h"
|
||||
#include "twi.h"
|
||||
|
||||
static volatile uint8_t twi_state;
|
||||
static volatile uint8_t twi_slarw;
|
||||
static volatile uint8_t twi_sendStop; // should the transaction end with a stop
|
||||
static volatile uint8_t twi_inRepStart; // in the middle of a repeated start
|
||||
|
||||
static void (*twi_onSlaveTransmit)(void);
|
||||
static void (*twi_onSlaveReceive)(uint8_t*, int);
|
||||
|
||||
static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH];
|
||||
static volatile uint8_t twi_masterBufferIndex;
|
||||
static volatile uint8_t twi_masterBufferLength;
|
||||
|
||||
static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH];
|
||||
static volatile uint8_t twi_txBufferIndex;
|
||||
static volatile uint8_t twi_txBufferLength;
|
||||
|
||||
static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH];
|
||||
static volatile uint8_t twi_rxBufferIndex;
|
||||
|
||||
static volatile uint8_t twi_error;
|
||||
|
||||
/*
|
||||
* Function twi_init
|
||||
* Desc readys twi pins and sets twi bitrate
|
||||
* Input none
|
||||
* Output none
|
||||
*/
|
||||
void twi_init(void)
|
||||
{
|
||||
// initialize state
|
||||
twi_state = TWI_READY;
|
||||
twi_sendStop = true; // default value
|
||||
twi_inRepStart = false;
|
||||
|
||||
// activate internal pullups for twi.
|
||||
digitalWrite(SDA, 1);
|
||||
digitalWrite(SCL, 1);
|
||||
|
||||
// initialize twi prescaler and bit rate
|
||||
cbi(TWSR, TWPS0);
|
||||
cbi(TWSR, TWPS1);
|
||||
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
|
||||
|
||||
/* twi bit rate formula from atmega128 manual pg 204
|
||||
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
|
||||
note: TWBR should be 10 or higher for master mode
|
||||
It is 72 for a 16mhz Wiring board with 100kHz TWI */
|
||||
|
||||
// enable twi module, acks, and twi interrupt
|
||||
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_disable
|
||||
* Desc disables twi pins
|
||||
* Input none
|
||||
* Output none
|
||||
*/
|
||||
void twi_disable(void)
|
||||
{
|
||||
// disable twi module, acks, and twi interrupt
|
||||
TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
|
||||
|
||||
// deactivate internal pullups for twi.
|
||||
digitalWrite(SDA, 0);
|
||||
digitalWrite(SCL, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_slaveInit
|
||||
* Desc sets slave address and enables interrupt
|
||||
* Input none
|
||||
* Output none
|
||||
*/
|
||||
void twi_setAddress(uint8_t address)
|
||||
{
|
||||
// set twi slave address (skip over TWGCE bit)
|
||||
TWAR = address << 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_setClock
|
||||
* Desc sets twi bit rate
|
||||
* Input Clock Frequency
|
||||
* Output none
|
||||
*/
|
||||
void twi_setFrequency(uint32_t frequency)
|
||||
{
|
||||
TWBR = ((F_CPU / frequency) - 16) / 2;
|
||||
|
||||
/* twi bit rate formula from atmega128 manual pg 204
|
||||
SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
|
||||
note: TWBR should be 10 or higher for master mode
|
||||
It is 72 for a 16mhz Wiring board with 100kHz TWI */
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_readFrom
|
||||
* Desc attempts to become twi bus master and read a
|
||||
* series of bytes from a device on the bus
|
||||
* Input address: 7bit i2c device address
|
||||
* data: pointer to byte array
|
||||
* length: number of bytes to read into array
|
||||
* sendStop: Boolean indicating whether to send a stop at the end
|
||||
* Output number of bytes read
|
||||
*/
|
||||
uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
// ensure data will fit into buffer
|
||||
if(TWI_BUFFER_LENGTH < length){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// wait until twi is ready, become master receiver
|
||||
while(TWI_READY != twi_state){
|
||||
continue;
|
||||
}
|
||||
twi_state = TWI_MRX;
|
||||
twi_sendStop = sendStop;
|
||||
// reset error state (0xFF.. no error occured)
|
||||
twi_error = 0xFF;
|
||||
|
||||
// initialize buffer iteration vars
|
||||
twi_masterBufferIndex = 0;
|
||||
twi_masterBufferLength = length-1; // This is not intuitive, read on...
|
||||
// On receive, the previously configured ACK/NACK setting is transmitted in
|
||||
// response to the received byte before the interrupt is signalled.
|
||||
// Therefor we must actually set NACK when the _next_ to last byte is
|
||||
// received, causing that NACK to be sent in response to receiving the last
|
||||
// expected byte of data.
|
||||
|
||||
// build sla+w, slave device address + w bit
|
||||
twi_slarw = TW_READ;
|
||||
twi_slarw |= address << 1;
|
||||
|
||||
if (true == twi_inRepStart) {
|
||||
// if we're in the repeated start state, then we've already sent the start,
|
||||
// (@@@ we hope), and the TWI statemachine is just waiting for the address byte.
|
||||
// We need to remove ourselves from the repeated start state before we enable interrupts,
|
||||
// since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning
|
||||
// up. Also, don't enable the START interrupt. There may be one pending from the
|
||||
// repeated start that we sent ourselves, and that would really confuse things.
|
||||
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
|
||||
do {
|
||||
TWDR = twi_slarw;
|
||||
} while(TWCR & _BV(TWWC));
|
||||
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
|
||||
}
|
||||
else
|
||||
// send start condition
|
||||
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
|
||||
|
||||
// wait for read operation to complete
|
||||
while(TWI_MRX == twi_state){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (twi_masterBufferIndex < length)
|
||||
length = twi_masterBufferIndex;
|
||||
|
||||
// copy twi buffer to data
|
||||
for(i = 0; i < length; ++i){
|
||||
data[i] = twi_masterBuffer[i];
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_writeTo
|
||||
* Desc attempts to become twi bus master and write a
|
||||
* series of bytes to a device on the bus
|
||||
* Input address: 7bit i2c device address
|
||||
* data: pointer to byte array
|
||||
* length: number of bytes in array
|
||||
* wait: boolean indicating to wait for write or not
|
||||
* sendStop: boolean indicating whether or not to send a stop at the end
|
||||
* Output 0 .. success
|
||||
* 1 .. length to long for buffer
|
||||
* 2 .. address send, NACK received
|
||||
* 3 .. data send, NACK received
|
||||
* 4 .. other twi error (lost bus arbitration, bus error, ..)
|
||||
*/
|
||||
uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
// ensure data will fit into buffer
|
||||
if(TWI_BUFFER_LENGTH < length){
|
||||
return 1;
|
||||
}
|
||||
|
||||
// wait until twi is ready, become master transmitter
|
||||
while(TWI_READY != twi_state){
|
||||
continue;
|
||||
}
|
||||
twi_state = TWI_MTX;
|
||||
twi_sendStop = sendStop;
|
||||
// reset error state (0xFF.. no error occured)
|
||||
twi_error = 0xFF;
|
||||
|
||||
// initialize buffer iteration vars
|
||||
twi_masterBufferIndex = 0;
|
||||
twi_masterBufferLength = length;
|
||||
|
||||
// copy data to twi buffer
|
||||
for(i = 0; i < length; ++i){
|
||||
twi_masterBuffer[i] = data[i];
|
||||
}
|
||||
|
||||
// build sla+w, slave device address + w bit
|
||||
twi_slarw = TW_WRITE;
|
||||
twi_slarw |= address << 1;
|
||||
|
||||
// if we're in a repeated start, then we've already sent the START
|
||||
// in the ISR. Don't do it again.
|
||||
//
|
||||
if (true == twi_inRepStart) {
|
||||
// if we're in the repeated start state, then we've already sent the start,
|
||||
// (@@@ we hope), and the TWI statemachine is just waiting for the address byte.
|
||||
// We need to remove ourselves from the repeated start state before we enable interrupts,
|
||||
// since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning
|
||||
// up. Also, don't enable the START interrupt. There may be one pending from the
|
||||
// repeated start that we sent outselves, and that would really confuse things.
|
||||
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
|
||||
do {
|
||||
TWDR = twi_slarw;
|
||||
} while(TWCR & _BV(TWWC));
|
||||
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
|
||||
}
|
||||
else
|
||||
// send start condition
|
||||
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA); // enable INTs
|
||||
|
||||
// wait for write operation to complete
|
||||
while(wait && (TWI_MTX == twi_state)){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (twi_error == 0xFF)
|
||||
return 0; // success
|
||||
else if (twi_error == TW_MT_SLA_NACK)
|
||||
return 2; // error: address send, nack received
|
||||
else if (twi_error == TW_MT_DATA_NACK)
|
||||
return 3; // error: data send, nack received
|
||||
else
|
||||
return 4; // other twi error
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_transmit
|
||||
* Desc fills slave tx buffer with data
|
||||
* must be called in slave tx event callback
|
||||
* Input data: pointer to byte array
|
||||
* length: number of bytes in array
|
||||
* Output 1 length too long for buffer
|
||||
* 2 not slave transmitter
|
||||
* 0 ok
|
||||
*/
|
||||
uint8_t twi_transmit(const uint8_t* data, uint8_t length)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
// ensure data will fit into buffer
|
||||
if(TWI_BUFFER_LENGTH < (twi_txBufferLength+length)){
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ensure we are currently a slave transmitter
|
||||
if(TWI_STX != twi_state){
|
||||
return 2;
|
||||
}
|
||||
|
||||
// set length and copy data into tx buffer
|
||||
for(i = 0; i < length; ++i){
|
||||
twi_txBuffer[twi_txBufferLength+i] = data[i];
|
||||
}
|
||||
twi_txBufferLength += length;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_attachSlaveRxEvent
|
||||
* Desc sets function called before a slave read operation
|
||||
* Input function: callback function to use
|
||||
* Output none
|
||||
*/
|
||||
void twi_attachSlaveRxEvent( void (*function)(uint8_t*, int) )
|
||||
{
|
||||
twi_onSlaveReceive = function;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_attachSlaveTxEvent
|
||||
* Desc sets function called before a slave write operation
|
||||
* Input function: callback function to use
|
||||
* Output none
|
||||
*/
|
||||
void twi_attachSlaveTxEvent( void (*function)(void) )
|
||||
{
|
||||
twi_onSlaveTransmit = function;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_reply
|
||||
* Desc sends byte or readys receive line
|
||||
* Input ack: byte indicating to ack or to nack
|
||||
* Output none
|
||||
*/
|
||||
void twi_reply(uint8_t ack)
|
||||
{
|
||||
// transmit master read ready signal, with or without ack
|
||||
if(ack){
|
||||
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
|
||||
}else{
|
||||
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_stop
|
||||
* Desc relinquishes bus master status
|
||||
* Input none
|
||||
* Output none
|
||||
*/
|
||||
void twi_stop(void)
|
||||
{
|
||||
// send stop condition
|
||||
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
|
||||
|
||||
// wait for stop condition to be exectued on bus
|
||||
// TWINT is not set after a stop condition!
|
||||
while(TWCR & _BV(TWSTO)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// update twi state
|
||||
twi_state = TWI_READY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function twi_releaseBus
|
||||
* Desc releases bus control
|
||||
* Input none
|
||||
* Output none
|
||||
*/
|
||||
void twi_releaseBus(void)
|
||||
{
|
||||
// release bus
|
||||
TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
|
||||
|
||||
// update twi state
|
||||
twi_state = TWI_READY;
|
||||
}
|
||||
|
||||
ISR(TWI_vect)
|
||||
{
|
||||
switch(TW_STATUS){
|
||||
// All Master
|
||||
case TW_START: // sent start condition
|
||||
case TW_REP_START: // sent repeated start condition
|
||||
// copy device address and r/w bit to output register and ack
|
||||
TWDR = twi_slarw;
|
||||
twi_reply(1);
|
||||
break;
|
||||
|
||||
// Master Transmitter
|
||||
case TW_MT_SLA_ACK: // slave receiver acked address
|
||||
case TW_MT_DATA_ACK: // slave receiver acked data
|
||||
// if there is data to send, send it, otherwise stop
|
||||
if(twi_masterBufferIndex < twi_masterBufferLength){
|
||||
// copy data to output register and ack
|
||||
TWDR = twi_masterBuffer[twi_masterBufferIndex++];
|
||||
twi_reply(1);
|
||||
}else{
|
||||
if (twi_sendStop)
|
||||
twi_stop();
|
||||
else {
|
||||
twi_inRepStart = true; // we're gonna send the START
|
||||
// don't enable the interrupt. We'll generate the start, but we
|
||||
// avoid handling the interrupt until we're in the next transaction,
|
||||
// at the point where we would normally issue the start.
|
||||
TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
|
||||
twi_state = TWI_READY;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TW_MT_SLA_NACK: // address sent, nack received
|
||||
twi_error = TW_MT_SLA_NACK;
|
||||
twi_stop();
|
||||
break;
|
||||
case TW_MT_DATA_NACK: // data sent, nack received
|
||||
twi_error = TW_MT_DATA_NACK;
|
||||
twi_stop();
|
||||
break;
|
||||
case TW_MT_ARB_LOST: // lost bus arbitration
|
||||
twi_error = TW_MT_ARB_LOST;
|
||||
twi_releaseBus();
|
||||
break;
|
||||
|
||||
// Master Receiver
|
||||
case TW_MR_DATA_ACK: // data received, ack sent
|
||||
// put byte into buffer
|
||||
twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
|
||||
case TW_MR_SLA_ACK: // address sent, ack received
|
||||
// ack if more bytes are expected, otherwise nack
|
||||
if(twi_masterBufferIndex < twi_masterBufferLength){
|
||||
twi_reply(1);
|
||||
}else{
|
||||
twi_reply(0);
|
||||
}
|
||||
break;
|
||||
case TW_MR_DATA_NACK: // data received, nack sent
|
||||
// put final byte into buffer
|
||||
twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
|
||||
if (twi_sendStop)
|
||||
twi_stop();
|
||||
else {
|
||||
twi_inRepStart = true; // we're gonna send the START
|
||||
// don't enable the interrupt. We'll generate the start, but we
|
||||
// avoid handling the interrupt until we're in the next transaction,
|
||||
// at the point where we would normally issue the start.
|
||||
TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
|
||||
twi_state = TWI_READY;
|
||||
}
|
||||
break;
|
||||
case TW_MR_SLA_NACK: // address sent, nack received
|
||||
twi_stop();
|
||||
break;
|
||||
// TW_MR_ARB_LOST handled by TW_MT_ARB_LOST case
|
||||
|
||||
// Slave Receiver
|
||||
case TW_SR_SLA_ACK: // addressed, returned ack
|
||||
case TW_SR_GCALL_ACK: // addressed generally, returned ack
|
||||
case TW_SR_ARB_LOST_SLA_ACK: // lost arbitration, returned ack
|
||||
case TW_SR_ARB_LOST_GCALL_ACK: // lost arbitration, returned ack
|
||||
// enter slave receiver mode
|
||||
twi_state = TWI_SRX;
|
||||
// indicate that rx buffer can be overwritten and ack
|
||||
twi_rxBufferIndex = 0;
|
||||
twi_reply(1);
|
||||
break;
|
||||
case TW_SR_DATA_ACK: // data received, returned ack
|
||||
case TW_SR_GCALL_DATA_ACK: // data received generally, returned ack
|
||||
// if there is still room in the rx buffer
|
||||
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
|
||||
// put byte in buffer and ack
|
||||
twi_rxBuffer[twi_rxBufferIndex++] = TWDR;
|
||||
twi_reply(1);
|
||||
}else{
|
||||
// otherwise nack
|
||||
twi_reply(0);
|
||||
}
|
||||
break;
|
||||
case TW_SR_STOP: // stop or repeated start condition received
|
||||
// ack future responses and leave slave receiver state
|
||||
twi_releaseBus();
|
||||
// put a null char after data if there's room
|
||||
if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
|
||||
twi_rxBuffer[twi_rxBufferIndex] = '\0';
|
||||
}
|
||||
// callback to user defined callback
|
||||
twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
|
||||
// since we submit rx buffer to "wire" library, we can reset it
|
||||
twi_rxBufferIndex = 0;
|
||||
break;
|
||||
case TW_SR_DATA_NACK: // data received, returned nack
|
||||
case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack
|
||||
// nack back at master
|
||||
twi_reply(0);
|
||||
break;
|
||||
|
||||
// Slave Transmitter
|
||||
case TW_ST_SLA_ACK: // addressed, returned ack
|
||||
case TW_ST_ARB_LOST_SLA_ACK: // arbitration lost, returned ack
|
||||
// enter slave transmitter mode
|
||||
twi_state = TWI_STX;
|
||||
// ready the tx buffer index for iteration
|
||||
twi_txBufferIndex = 0;
|
||||
// set tx buffer length to be zero, to verify if user changes it
|
||||
twi_txBufferLength = 0;
|
||||
// request for txBuffer to be filled and length to be set
|
||||
// note: user must call twi_transmit(bytes, length) to do this
|
||||
twi_onSlaveTransmit();
|
||||
// if they didn't change buffer & length, initialize it
|
||||
if(0 == twi_txBufferLength){
|
||||
twi_txBufferLength = 1;
|
||||
twi_txBuffer[0] = 0x00;
|
||||
}
|
||||
// transmit first byte from buffer, fall
|
||||
case TW_ST_DATA_ACK: // byte sent, ack returned
|
||||
// copy data to output register
|
||||
TWDR = twi_txBuffer[twi_txBufferIndex++];
|
||||
// if there is more to send, ack, otherwise nack
|
||||
if(twi_txBufferIndex < twi_txBufferLength){
|
||||
twi_reply(1);
|
||||
}else{
|
||||
twi_reply(0);
|
||||
}
|
||||
break;
|
||||
case TW_ST_DATA_NACK: // received nack, we are done
|
||||
case TW_ST_LAST_DATA: // received ack, but we are done already!
|
||||
// ack future responses
|
||||
twi_reply(1);
|
||||
// leave slave receiver state
|
||||
twi_state = TWI_READY;
|
||||
break;
|
||||
|
||||
// All
|
||||
case TW_NO_INFO: // no state information
|
||||
break;
|
||||
case TW_BUS_ERROR: // bus error, illegal stop/start
|
||||
twi_error = TW_BUS_ERROR;
|
||||
twi_stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
twi.h - TWI/I2C library for Wiring & Arduino
|
||||
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef twi_h
|
||||
#define twi_h
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
//#define ATMEGA8
|
||||
|
||||
#ifndef TWI_FREQ
|
||||
#define TWI_FREQ 100000L
|
||||
#endif
|
||||
|
||||
#ifndef TWI_BUFFER_LENGTH
|
||||
#define TWI_BUFFER_LENGTH 32
|
||||
#endif
|
||||
|
||||
#define TWI_READY 0
|
||||
#define TWI_MRX 1
|
||||
#define TWI_MTX 2
|
||||
#define TWI_SRX 3
|
||||
#define TWI_STX 4
|
||||
|
||||
void twi_init(void);
|
||||
void twi_disable(void);
|
||||
void twi_setAddress(uint8_t);
|
||||
void twi_setFrequency(uint32_t);
|
||||
uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
|
||||
uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
|
||||
uint8_t twi_transmit(const uint8_t*, uint8_t);
|
||||
void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
|
||||
void twi_attachSlaveTxEvent( void (*)(void) );
|
||||
void twi_reply(uint8_t);
|
||||
void twi_stop(void);
|
||||
void twi_releaseBus(void);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue