Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hc24 pad #5

Closed
wants to merge 14 commits into from
10 changes: 10 additions & 0 deletions hackpads/hc24 pad/CAD/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Case

for the 2nd cad i've ever designed, dosent look all too that bad!<br/>

**I perfer getting it machined, but if thats not possible, 3d prints work for me too!<br/>**
**base.stl:** made from a white/transparent please<br/>
**top.stl:** black. just black :)<br/>
![image](https://github.com/user-attachments/assets/04ad864e-5b56-4508-ab3a-e111c22ad6d4)
![image](https://github.com/user-attachments/assets/593ce748-4119-4ad5-b491-d3a69ea26d91)

Binary file added hackpads/hc24 pad/CAD/base.stl
Binary file not shown.
Binary file added hackpads/hc24 pad/CAD/top.stl
Binary file not shown.
6 changes: 6 additions & 0 deletions hackpads/hc24 pad/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# hackclub 24 pad
with love, from swirly!
![image](https://github.com/user-attachments/assets/6f83f020-a5ce-4086-ad1a-7a605ca76dfe)
![image](https://github.com/user-attachments/assets/7f277403-bbd4-4984-9d08-49a98737e0b2)
![image](https://github.com/user-attachments/assets/83e3af63-4460-4a28-963a-8e065bafd167)
![image](https://github.com/user-attachments/assets/dc6474c2-dd23-49e7-a028-ab8ffbde19d5)
103 changes: 103 additions & 0 deletions hackpads/hc24 pad/firmware/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
from machine import Pin, I2C, RTC
import neopixel
import time
import usb_hid
import colorsys
import ssd1315

NUM_LEDS = 28
LED_PIN = 18
BUTTON_PINS = [0, 1, 2, 3, 7, 6, 9, 10]
KEYS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']

np = neopixel.NeoPixel(Pin(LED_PIN), NUM_LEDS)

buttons = [Pin(pin, Pin.IN, Pin.PULL_UP) for pin in BUTTON_PINS]

keyboard_device = usb_hid.devices[0]

i2c = I2C(0, scl=Pin(19), sda=Pin(18))
display = ssd1315.SSD1315_I2C(128, 64, i2c)

rtc = RTC()

transition_speed = 0.01
hue = 0

def hsv_to_rgb(h, s, v):
"""Convert HSV to RGB."""
if s == 0.0:
r = g = b = int(v * 255)
return (r, g, b)

i = int(h * 6.0)
f = (h * 6.0) - i
p = v * (1.0 - s)
q = v * (1.0 - s * f)
t = v * (1.0 - s * (1.0 - f))
i = i % 6

if i == 0:
r, g, b = v, t, p
elif i == 1:
r, g, b = q, v, p
elif i == 2:
r, g, b = p, v, t
elif i == 3:
r, g, b = p, q, v
elif i == 4:
r, g, b = t, p, v
elif i == 5:
r, g, b = v, p, q

return (int(r * 255), int(g * 255), int(b * 255))

def set_button_leds(color):
"""Set color for the button LEDs."""
for i in range(16):
np[i] = color
np.write()

def set_transition_leds():
"""Set color for the transition LEDs."""
global hue
for i in range(16, NUM_LEDS):
np[i] = hsv_to_rgb(hue, 1, 1)
np.write()
hue += transition_speed
if hue > 1:
hue -= 1

def check_buttons():
"""Check button presses and handle LEDs and keystrokes."""
for i, button in enumerate(buttons):
if not button.value():

set_button_leds((0, 0, 255))

if i < len(KEYS):
keyboard_device.send(KEYS[i])
return

set_button_leds((0, 0, 0))
set_transition_leds()

def display_time():
"""Display the current time on the SSD1315 display."""

t = rtc.datetime()
hours = t[4]
minutes = t[5]
seconds = t[6]

display.fill(0)

time_str = "{:02}:{:02}:{:02}".format(hours, minutes, seconds)

display.text(time_str, 0, 0)
display.show()

while True:
check_buttons()
display_time()
time.sleep(0.1)
Binary file added hackpads/hc24 pad/pcb/BOM_macro_2024-09-16.csv
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions hackpads/hc24 pad/pcb/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Made with love, swirly
Btw, to whoever is reading this, I'd like a black pcb please!

![image](https://github.com/user-attachments/assets/8149a1e7-f47d-4c23-b0f5-0ba76c557410)
![image](https://github.com/user-attachments/assets/9f8b5942-2080-4fae-80e4-427d4774c714)
![image](https://github.com/user-attachments/assets/833b3fc5-f630-440a-ae94-7e870f171594)
![image](https://github.com/user-attachments/assets/298de7ea-fce7-48e3-8234-dc62e00e8e4c)
![image](https://github.com/user-attachments/assets/ac493695-45ae-40d0-928a-fb361bdc3d40)