Browse Source

In progress...

master
Ruel Tmeizeh - RuhNet 1 year ago
commit
23e8ebba18
4 changed files with 247 additions and 0 deletions
  1. +1
    -0
      .gitignore
  2. +237
    -0
      LED_Multiplex_Display.ino
  3. +9
    -0
      LICENSE.md
  4. BIN
      demo.jpg

+ 1
- 0
.gitignore View File

@ -0,0 +1 @@
*.swp

+ 237
- 0
LED_Multiplex_Display.ino View File

@ -0,0 +1,237 @@
//Copyright 2023 RuhNet
//All rights reserved.
//MIT Licensed.
#define LOW 1
#define HIGH 0
//br = bottom right segment
//top = top segment
//bl = bottom left segment
//b = bottom segment
//mid = mid segment
//tr = top right segment
//tl = top left segment
//PORTC 1 1 1 1 1 1 1 1
// br . top bl b mid tr tl
void writeDigit(byte displayCharacter, uint8_t position);
void writeDisplay(char displayString[]);
void loadDisplay(byte stringArr[]);
byte segment_cursor = 1; //which segment to light up
uint8_t cursor = 0; //position on display
//PORTC is wired to each segment through a 200ohm resistor
//PORTC 1 1 1 1 1 1 1 1
// br . top bl b mid tr tl
uint8_t seg_br = bit(7);
uint8_t seg_dot = bit(6);
uint8_t seg_top = bit(5);
uint8_t seg_bl = bit(4);
uint8_t seg_bot = bit(3);
uint8_t seg_mid = bit(2);
uint8_t seg_tr = bit(1);
uint8_t seg_tl = bit(0);
//characterset
const byte c_space = 0x00;
const byte c_0 = seg_br + seg_top + seg_bl + seg_bot + seg_tr + seg_tl; //0b10111011
const byte c_1 = seg_tr + seg_br; //0b10000010
const byte c_2 = seg_top + seg_bl + seg_bot + seg_mid + seg_tr; //0b00111110
const byte c_3 = seg_br + seg_top + seg_bot + seg_mid + seg_tr;
const byte c_4 = seg_br + seg_mid + seg_tr + seg_tl;
const byte c_5 = seg_br + seg_top + seg_bot + seg_mid + seg_tl;
const byte c_6 = seg_br + seg_top + seg_bl + seg_bot + seg_mid + seg_tl; //0b10111101
const byte c_7 = seg_br + seg_top + seg_tr; //0b10100010
const byte c_8 = seg_br + seg_top + seg_bl + seg_bot + seg_mid + seg_tr + seg_tl; //0b10111111;
const byte c_9 = seg_br + seg_top + seg_bot + seg_mid + seg_tr + seg_tl; //0b11101111
const byte c_dot = seg_dot; //0b01000000
const byte c_A = seg_br + seg_top + seg_bl + +seg_mid + seg_tr + seg_tl; //0b10110111
const byte c_B = seg_br + seg_bl + seg_bot + seg_mid + seg_tl;
const byte c_C = seg_bl + seg_bot + seg_mid;
const byte c_D = seg_br + seg_bl + seg_bot + seg_mid + seg_tr;
const byte c_E = seg_top + seg_bl + seg_bot + seg_mid + seg_tl;
const byte c_F = seg_top + seg_bl + seg_mid + seg_tl; //0b00110101
const byte c_G = seg_br + seg_top + seg_bl + seg_bot + seg_tl;
const byte c_H = seg_br + seg_bl + seg_mid + seg_tr + seg_tl;
const byte c_I = seg_bl;
const byte c_J = seg_br + seg_bl + seg_bot + seg_tr;
const byte c_K = seg_br + seg_bl + seg_mid + seg_tr + seg_tl + seg_dot;
const byte c_L = seg_bl + seg_bot + seg_tl;
const byte c_M = seg_br + seg_bl + seg_mid;
const byte c_N = seg_br + seg_bl + seg_mid;
const byte c_O = seg_br + seg_bl + seg_mid + seg_bot;
const byte c_P = seg_top + seg_bl + seg_mid + seg_tr + seg_tl;
const byte c_Q = seg_br + seg_top + seg_bl + seg_bot + seg_tr + seg_tl + seg_dot;
const byte c_R = seg_br + seg_top + seg_bl + seg_mid + seg_tr + seg_tl;
const byte c_S = seg_br + seg_top + seg_bot + seg_mid + seg_tl;
const byte c_T = seg_br + seg_top + seg_tr;
const byte c_U = seg_br + seg_bl + seg_bot;
const byte c_V = seg_br + seg_bl + seg_bot;
const byte c_W = seg_br + seg_bl + seg_bot + seg_tr + seg_tl;
const byte c_X = seg_br + seg_bl + seg_mid + seg_tr + seg_tl + seg_dot;
const byte c_Y = seg_br + seg_mid + seg_tr + seg_tl;
const byte c_Z = seg_top + seg_bl + seg_bot + seg_mid + seg_tr;
byte numberSet[11] = {
c_0,
c_1,
c_2,
c_3,
c_4,
c_5,
c_6,
c_7,
c_8,
c_9,
c_dot
};
//byte displayOutput[8] = { c_a, c_b, c_c, 0b11111111, c_2, c_3, c_4, c_5 };
//byte displayOutput[8] = { c_H, c_E, c_L, c_L, c_O, c_dot, c_4, c_5 };
//byte displayOutput[8] = { c_R, c_U, c_H, c_N, c_E, c_T, 0, 0 };
byte displayOutput[] = { c_G, c_P, c_S, c_dot, c_L, c_O, c_C, c_K };
void writeDigit(byte displayCharacter, uint8_t position) {
//segment_cursor = 1;
//PORTA = 0b10101010;
//PORTA = 0xff;
PORTA = (0xff & ~(1 << position));
for (uint8_t i = 0; i < 8; i++) {
PORTC = (displayCharacter & segment_cursor);
//PORTC = displayCharacter;
//delay(1);
//segment_cursor = segment_cursor << 1; //shift bit to left
/*
if (displayCharacter & segment_cursor) {
PORTA = (0 << cursor); //Enable the character to write this segment
} else {
PORTA = 0xff;
}
*/
}
}
void writeDisplay(char displayString[8]) {
for (uint8_t i = 0; i < 8; i++) {
writeDigit(displayString[i], i);
}
}
void setup() {
OSCCAL = 0xad;
//pinMode(led, OUTPUT);
DDRA = 0xff; //set all of port A as output
DDRC = 0xff;
PORTA = 0b10111111;
PORTC = 0b10111011;
PORTA = 0b11101111;
PORTC = 0b10000111;
PORTA = 0x00;
PORTC = 0b01000000;
/*
TCCR2 PRESCALER:
CS22 CS21 CS20
0 0 1 2
0 1 0 8
0 1 1 32
1 0 0 64
1 0 1 128
1 1 0 256
1 1 1 1024
*/
noInterrupts(); // disable all interrupts
TCCR2 = 0;
//TCNT2 = 150; // preload timer
//TCCR1B |= (1 << CS22) | (1 << CS21) | (1 << CS20); // 1024 prescaler
TCCR2 |= (1 << CS21); // prescaler 8
TIMSK |= (1 << TOIE2); // enable timer overflow interrupt ISR
interrupts();
//PORTA = 0b11100011;
PORTA = 0b00100111;
//PORTA = 0x00;
}
ISR(TIMER2_OVF_vect) { //WRITE DISPLAY!
//WRITE DISPLAY
TCNT2 = 192; //set timer value to set refresh rate -- lower is slower
PORTA = 0xff;
if (displayOutput[cursor] & segment_cursor) PORTA &= ~(1 << cursor);
//writeDigit(displayOutput[cursor], cursor);
PORTC = (displayOutput[cursor] & segment_cursor);
if (segment_cursor < 0b10000000) {
segment_cursor = segment_cursor << 1;
} else {
segment_cursor = 1;
if (cursor < 7) {
cursor++;
} else {
cursor = 0;
}
}
}
void loadDisplay(byte stringArr[]) {
for (uint8_t i = 0; i < 8; i++) {
displayOutput[i] = stringArr[i];
}
}
void loop() {
byte dp1[8] = { c_G, c_P, c_S, c_dot, c_L, c_O, c_C, c_K }; //GPS.LOCK
loadDisplay(dp1);
delay(1000);
byte dp2[8] = { c_3, (c_6 | (1 << 6)), c_4, c_7, c_3, c_9, c_2, c_N }; //36.47392N --- the bitshift turns the dot on along with the 6.
loadDisplay(dp2);
delay(1000);
byte dp3[8] = { c_C, c_L, c_O, c_C, c_K, 0, 0, 0 }; //CLOCK
loadDisplay(dp3);
delay(1000);
byte dp4[8] = { c_1, c_2, c_dot, c_5, c_4 , c_dot, c_3, c_7 }; //12.54.37
loadDisplay(dp4);
delay(1000);
displayOutput[7] = c_8;
delay(1000);
displayOutput[7] = c_9;
loadDisplay(displayOutput);
delay(1000);
displayOutput[6] = c_4;
displayOutput[7] = c_0;
delay(1000);
displayOutput[7] = c_1;
delay(1000);
displayOutput[7] = c_2;
delay(1000);
displayOutput[7] = c_3;
delay(1000);
displayOutput[7] = c_4;
delay(1000);
displayOutput[7] = c_5;
delay(1000);
displayOutput[7] = c_6;
delay(1000);
}

+ 9
- 0
LICENSE.md View File

@ -0,0 +1,9 @@
# Released under MIT License
Copyright (c) 2023 RuhNet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

BIN
demo.jpg View File

Before After
Width: 3364  |  Height: 2304  |  Size: 334 KiB

Loading…
Cancel
Save