From 524befe3ae7273c00b04589b723bf22a4593f010 Mon Sep 17 00:00:00 2001
From: ebp1g21 <ebp1g21@soton.ac.uk>
Date: Sat, 13 May 2023 20:37:26 +0000
Subject: [PATCH] Upload New File

---
 stub.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 stub.c

diff --git a/stub.c b/stub.c
new file mode 100644
index 0000000..359bc13
--- /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
+}
-- 
GitLab