diff --git a/stub.c b/stub.c new file mode 100644 index 0000000000000000000000000000000000000000..359bc1342786511b4c9f14c0c044c62a3e0012df --- /dev/null +++ b/stub.c @@ -0,0 +1,66 @@ +#include "pico/stdlib.h" +#include "hardware/pwm.h" +#include "hardware/clocks.h" + +#define BUZZER_PIN 18 // This is both the buzzer and audio jack (just in case you have anything to plug into it) + +#define BUTTON_1_PIN 20 +#define BUTTON_2_PIN 21 +#define BUTTON_3_PIN 22 + +#define FREQ_1 261.6256f +#define FREQ_2 293.6648f +#define FREQ_3 329.6276f + +/** + * A method for playing a note on the speaker. + * @param frequency Frequency of the note in Hz. +*/ +void playNote(float frequency) { + + // TODO - make a note of that frequency play on the buzzer + +} + +/** + * A method for silencing the speaker. +*/ +void playNothing() { + + // TODO - make the buzzer be silent + +} + +/** + * A method for handling GPIO events. + * @param gpio GPIO Number. + * @param event_mask Which events will cause an interrupt. See gpio_irq_level for details. +*/ +void handleEvent(uint gpio, uint32_t event_mask) { + + // TODO - link the events to the play methods + +} + +int main() { + stdio_init_all(); + + // Setting up the buzzer + gpio_set_function(BUZZER_PIN, GPIO_FUNC_PWM); + + // Linking the buttons to the event handler + gpio_set_irq_enabled_with_callback(BUTTON_1_PIN, GPIO_IRQ_EDGE_FALL, true, &handleEvent); + gpio_set_irq_enabled_with_callback(BUTTON_2_PIN, GPIO_IRQ_EDGE_FALL, true, &handleEvent); + gpio_set_irq_enabled_with_callback(BUTTON_3_PIN, GPIO_IRQ_EDGE_FALL, true, &handleEvent); + + gpio_set_irq_enabled_with_callback(BUTTON_1_PIN, GPIO_IRQ_EDGE_RISE, true, &handleEvent); + gpio_set_irq_enabled_with_callback(BUTTON_2_PIN, GPIO_IRQ_EDGE_RISE, true, &handleEvent); + gpio_set_irq_enabled_with_callback(BUTTON_3_PIN, GPIO_IRQ_EDGE_RISE, true, &handleEvent); + + // Main Program Loop + while (true) { + tight_loop_contents(); + } + + return 0; // This will never be reached +}