Skip to content

Commit

Permalink
Merge pull request #10 from gabrielosorio/wakie_message
Browse files Browse the repository at this point in the history
Wakie message
  • Loading branch information
gabrielosorio authored May 29, 2023
2 parents f8ae3b6 + 3e45b38 commit 1ff8885
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Wakie

![Alarm Display Wide](/hardware/alarm_display_wide.png?raw=true "Alarm Display")

Vector graphics from wokwi.com.

## Overview

An RTC-based alarm clock built for no good reason.
I bricked my phone in an utter state of DIY hubris.
To make up for one of the utilities lost in the aftermath, I put together an alarm clock with parts I had laying around.

## Hardware

Expand All @@ -19,6 +24,7 @@ Components in the wiring diagram are merely illustrative and do not necessarily
<table>
<tr>
<td valign="top">
<h4>Components</h4>
<ol>
<li>Arduino Nano</li>
<li>DS1307 (Tiny RTC)</li>
Expand All @@ -38,6 +44,11 @@ Components in the wiring diagram are merely illustrative and do not necessarily
</tr>
</table>

### Gallery

![Alarm Display](/hardware/alarm_display.png?raw=true "Alarm Display")
![Date-Time Display](/hardware/datetime_display.png?raw=true "DateTime Display")

## License

[AGPL 3.0](LICENSE)
Binary file added hardware/alarm_display.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hardware/alarm_display_wide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hardware/alarm_display_wide_transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hardware/datetime_display.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 33 additions & 15 deletions wakie.ino
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ void setup() {
// Interrupts
attachInterrupt(digitalPinToInterrupt(BUTTON), buttonInterrupt, FALLING);

lcd.begin(16, 2);

pinMode(BUTTON, INPUT);
pinMode(LCD_LED, OUTPUT);
enableLcdBacklight();
Expand All @@ -79,30 +81,28 @@ void loop() {

handleLcdBacklightDimming();

if (currentMinute != lastMinute) {
lastMinute = currentMinute;
renderDisplay();
}

// Current duration is within the specified alarmMinute
if (alarmTimeIsReached()) {
if (!alarmDeactivated) {
soundAlarm();
}
if (alarmTimeIsReached() && !alarmDeactivated) {
soundAlarm();
} else {
// Outside of the alarm window reset the
// alarmDeactivated check if it's enabled
if (alarmDeactivated) {
alarmDeactivated = false;
if (currentMinute != lastMinute) {
lastMinute = currentMinute;
renderDisplay();
}
}

// Outside of the alarm window reset the
// alarmDeactivated check if it's enabled
if (!alarmTimeIsReached() && alarmDeactivated) {
alarmDeactivated = false;
}
}

void buttonInterrupt() {
Serial.println("Button pressed");

// Use button to deactivate alarm if currently sounding
if (alarmTimeIsReached()) {
if (alarmTimeIsReached() && !alarmDeactivated) {
alarmDeactivated = true;
} else {
// Otherwise use button to toggle backlight on/off
Expand All @@ -128,14 +128,19 @@ void readRtc() {
void renderDisplay() {
char formatOutput[2]; // Buffer to process number formatting

lcd.clear();

// Time
lcd.begin(16, 2);
numberToDoubleDigitChar(currentHour, formatOutput);
lcd.print(formatOutput); // Hour
lcd.print(":");
numberToDoubleDigitChar(currentMinute, formatOutput);
lcd.print(formatOutput); // Minute

// Idle Wakie
lcd.setCursor(0, 1);
lcd.print("WAKIE");

// Vertical spacer
lcd.setCursor(6, 0);
lcd.print("|");
Expand Down Expand Up @@ -187,6 +192,19 @@ void soundAlarm() {
// Keep LCD backlight on during the alarm
enableLcdBacklight();

char formatOutput[2]; // Buffer to process number formatting

// WAKIE
lcd.clear();
lcd.setCursor(4, 0);
numberToDoubleDigitChar(alarmHour, formatOutput);
lcd.print(formatOutput); // Hour
lcd.print(" : ");
numberToDoubleDigitChar(alarmMinute, formatOutput);
lcd.print(formatOutput); // Minute
lcd.setCursor(3, 1);
lcd.print("W A K I E");

// Go through the note bitmap rows
for (uint8_t row = 0; row < noteBitmapRows; row++) {
// Go through the columns in the note bitmap row
Expand Down

0 comments on commit 1ff8885

Please sign in to comment.