Skip to content

Commit

Permalink
add rgb led support (unused for now, doesn't compile) and update case…
Browse files Browse the repository at this point in the history
… designs
  • Loading branch information
Matteo Forlani committed Nov 11, 2023
1 parent bf831f9 commit 9753c5a
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:
./build.sh

clean:
./clean.sh
Binary file modified case/bottom.stl
Binary file not shown.
Binary file modified case/top.stl
Binary file not shown.
28 changes: 28 additions & 0 deletions qmk/cvntpad/keymaps/default/cvntled.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "cvntled.h"

void cvntled_new(CvntLed* led,
unsigned int com_pin, unsigned int red_pin,
unsigned int green_pin, unsigned int blue_pin,
RGBLedType led_type)
{
led = malloc(sizeof(CvntLed));
led->comPin = com_pin;
led->redPin = red_pin;
led->greenPin = green_pin;
led->bluePin = blue_pin;
led->type = led_type;

// Turn led on
writePin(led->comPin, (led->type == COM_ANODE) ? 1 : 0);
}

void cvntled_set(CvntLed* led, bool r, bool g, bool b) {
writePin(led->redPin, (int)r);
writePin(led->greenPin, (int)g);
writePin(led->bluePin, (int)b);
}

void cvntled_toggle(CvntLed* led) {
int comPinValue = readPin(led->comPin);
writePin(led->comPin, !comPinValue);
}
31 changes: 31 additions & 0 deletions qmk/cvntpad/keymaps/default/cvntled.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include QMK_KEYBOARD_H

typedef enum RGBLedType {
COM_ANODE,
COM_CATHODE
} RGBLedType;

typedef struct CvntLed {
// Common anode/cathode pin
unsigned int comPin;
// Red Pin
unsigned int redPin;
// Green Pin
unsigned int greenPin;
// Blue Pin
unsigned int bluePin;
// Led type (common anode/cathode)
RGBLedType type;
} CvntLed;

// Create a new CvntLed "object"
void cvntled_new(CvntLed* led,
unsigned int com_pin, unsigned int red_pin,
unsigned int green_pin, unsigned int blue_pin,
RGBLedType led_type);

// Set RGB LED Color
void cvntled_set(CvntLed* led, bool r, bool g, bool b);

// Toggle On/Off State
void cvntled_toggle(CvntLed* led);
14 changes: 14 additions & 0 deletions qmk/cvntpad/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include QMK_KEYBOARD_H
// #include "cvntled.h"

#define MIDI_ADVANCED

Expand All @@ -10,11 +11,24 @@ extern MidiDevice midi_device;
#define MIDI_CC_OFF 0
#define MIDI_CC_ON 127

// #define COM_PIN GP26
// #define RED_PIN GP27
// #define GREEN_PIN GP28
// #define BLUE_PIN GP29

// CvntLed* thatLed;

enum custom_keycodes {
MIDI_CC80 = SAFE_RANGE,
};

// void bootmagic_lite(void) {
// cvntled_new(thatLed, COM_PIN, RED_PIN, GREEN_PIN, BLUE_PIN, COM_CATHODE);
// }

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// should be red ig!
// cvntled_set(thatLed, 1, 0, 0);
switch(keycode) {
case MIDI_CC80:

Expand Down

0 comments on commit 9753c5a

Please sign in to comment.