VDosda / Crossfit_Timer

Crossfit Timer with Arduino
MIT License
7 stars 0 forks source link

Using your code with my hardware design (42 WS2812B LEDs per digit - 6 LEDs) #1

Open motechsolutions opened 3 years ago

motechsolutions commented 3 years ago

Hi Im hoping you can help me update your code to work with my hardware design.

Im using 42 WS2812B Leds per 7 segment digit (6 Leds per digit segment)(Main 4 digits), two far left smaller digits are 17 Leds per digit (3 Leds on segments going across and 2 Leds for segments going down) to show UP or DOWN.

Two buttons (Red for stop and/or pause, Green for start )

The 16X Keypad is to allow me to enter the session time for work/rest and laps (Example: if i enter 10 on the keypad then the display shows 00:10 but if i enter 110 then the display shows 01:10, same for rest time then last part of setup is number of laps)

Can you help me update your code to work like this with my hardware as im a Arduino coding noob :)

gym-timer Gym Timer.pdf

VDosda commented 3 years ago

Hello Michael,

First of all, that’s a nice project ! :) Sure, I can try to help you with your code !

If you have a bit more info, did you start to create a peace of code that I can check? It will help me to understand and think about how I can adapt my code.

Le mer. 26 mai 2021 à 16:13, Michael Moane @.***> a écrit :

Hi Im hoping you can help me update your code to work with my hardware design.

Im using 42 WS2812B Leds per 7 segment digit (6 Leds per digit segment)(Main 4 digits), two far left smaller digits are 17 Leds per digit (3 Leds on segments going across and 2 Leds for segments going down) to show UP or DOWN.

Two buttons (Red for stop and/or pause, Green for start )

The 16X Keypad is to allow me to enter the session time for work/rest and laps (Example: if i enter 10 on the keypad then the display shows 00:10 but if i enter 110 then the display shows 01:10, same for rest time then last part of setup is number of laps)

Can you help me update your code to work like this with my hardware as im a Arduino coding noob :)

[image: gym-timer] https://user-images.githubusercontent.com/6040496/119674874-7aa2d280-be34-11eb-99d3-afaec2064343.gif Gym Timer.pdf https://github.com/VDosda/Crossfit_Timer/files/6547282/Gym.Timer.pdf

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/VDosda/Crossfit_Timer/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADXJAXFVYZSV7AVA766JOCTTPT6YNANCNFSM45SEQTCQ .

motechsolutions commented 3 years ago

Hi again The project started when i found this crossfit timer project (https://www.youtube.com/watch?v=anBJnOmhjhE) but i didn't like only using two leds per segment and 3 buttons so i changed these stl files to the design in the image above. My though was if i use 6 X WS2812B leds per segment i will get a better spread of light over the segment and if needed i can increase/decrease the brightness. The reason for the keypad was to make entering the work/rest/laps times easier :) well that was the thought!! The original design used a ESP32 as the microcontroller which i started with but after reading up on microcontroller choices for makers and how sometimes a simpler microcontroller give better program stability i changed over to using the Arduino Nano. That choice lead me to find your project :) The main problem ive been facing is i have 172 leds in the first string (34 in the second that controls the two smaller digits on the left) and in the original design they used a binary string to set the leds per digit and i had 42 bits which is to much for a int or a long integer. (https://github.com/PlumPot55/SevenSegment_Dispay). I then found some code that addressed each segment as a block on leds (https://learn.adafruit.com/ninja-timer-giant-7-segment-display/build-the-circuit), i liked the way he coded this but my coding skills are not up to that :) This lead me to using a Arduino Nano, i thought using a 8bit Microcontroller instead of a 32bit ESP32 would make the code a bit easier :) but as my coding skills are not that good and im struggling.

The design is: Main Digits: 42 leds per digit (6 per segment), 2 leds per dot (2 X 2 dots = 4 leds), 172 leds total (Nano pin D3) Sub digits (far left): 17 leds per digit, 34 total (Nano pin D2) to show UP/DN and other program indicators like memory save position like P1/P2/P3/P4 Piezo buzzer = https://thepihut.com/products/large-enclosed-piezo-element-w-wires?variant=27739589457 RTC=DS3231 Keypad=16 key Switch Membrane Matrix KeyPad (Hopefully use A,B,C,D keys to store as retrieve saved session settings like tabata and other custom session types ) Microcontroller=Arduino Nano

I have used the FastLed example CRGBSet_7segment_3digits.ino to prove all leds in each string work :)

Sorry for the long reply but i was trying to give you as much info as possible about my design

motechsolutions commented 3 years ago

sorry forgot to add i want to use your code as i like the using the RTC so the timing is spot on :) i just need to get it to work with my hardware design, then piece by piece get all the functions included :)

Also i got this Fastled example to work with my first two main digits and i like the way it splits the segments into blocks, segA, segB, segC, segD, segE, segF, segG make working with the segments far easier for me :)

`#include "FastLED.h"

define DATA_PIN 3

define LED_TYPE WS2812B

define COLOR_ORDER GRB

define NUM_LEDS 172

define BRIGHTNESS 50

define FRAMES_PER_SECOND 120

uint8_t pps = 6; // number of Pixels Per Segment CHSV segON10(96,200,255); // color of 10s digit segments CHSV segON(42,255,255); // color of 1s digit segments

/ CRGB leds[NUM_LEDS]; <--not using this. Using CRGBArray instead. / CRGBArray leds;

// Name segments (based on layout in link above) and define pixel ranges. CRGBSet segA( leds(pps0, pps-1+(pps0) )); CRGBSet segB( leds(pps1, pps-1+(pps1) )); CRGBSet segC( leds(pps2, pps-1+(pps2) )); CRGBSet segD( leds(pps3, pps-1+(pps3) )); CRGBSet segE( leds(pps4, pps-1+(pps4) )); CRGBSet segF( leds(pps5, pps-1+(pps5) )); CRGBSet segG( leds(pps6, pps-1+(pps6) ));

uint8_t count = 0; // keeps track of what number to display

//--------------------------------------------------------------- void setup() { Serial.begin(115200); // Allows serial monitor output (check baud rate) delay(3000); // 3 second delay for recovery //FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); FastLED.setBrightness(BRIGHTNESS); FastLED.clear(); // Initially clear all pixels }

//--------------------------------------------------------------- void loop() { EVERY_N_MILLISECONDS(1000){ setSegments(count); // Determine which segments are ON or OFF count++; // Advance the count by one if (count > 25) { count = 0; } // Reset count back to zero } FastLED.delay(1000/FRAMES_PER_SECOND); }

//--------------------------------------------------------------- void setSegments(uint8_t count){ // Based on the current count set number segments on or off uint8_t c1 = 0; // Variable to store 1s digit uint8_t c10 = 0; // Variable to store 10s digit uint8_t c; CHSV segCOLOR(0,0,0);

if (count > 9) { // Split out 1s and 10s digits if count is greater then 9 c1 = count % 10; c10 = count / 10; } else { c1 = count; c10 = 0; }

//Serial.print("count = "); Serial.print(count); // Print to serial monitor current count //Serial.print("\t 10s: "); Serial.print(c10); // Print 10s digit //Serial.print(" 1s: "); Serial.println(c1); // Print 1s digit

// Operate on 1s digit segments first, shift them over, and then do the 10s digit segments for (uint8_t i=0; i < 2; i++) { if (i == 0) { c = c10; segCOLOR = seg10ON; } else { c = c1; segCOLOR = segON; }

segA = segB = segC = segD = segE = segF = segG = CRGB::Black;  // Initially set segments off

  if (c == 0) { segA = segB = segC = segE = segF = segG = segCOLOR; }
if (c == 1) { segA = segE = segCOLOR; }
if (c == 2) { segA = segB = segD = segF = segG = segCOLOR; }
if (c == 3) { segA = segB = segD = segE = segF = segCOLOR; }
if (c == 4) { segA = segC = segD = segE = segCOLOR; }
if (c == 5) { segB = segC = segD = segE = segF = segCOLOR; }
if (c == 6) { segB = segC = segD = segE = segF = segG = segCOLOR; }
if (c == 7) { segA = segB = segE = segCOLOR; }
if (c == 8) { segA = segB = segC = segD = segE = segF = segG = segCOLOR; }
if (c == 9) { segA = segB = segC = segD = segE = segCOLOR; }

if (i == 0) {  // Shift segments over to 1s digit display area
  for (uint8_t p=0; p < (7*pps); p++) {
    leds[p+(7*pps)] = leds[p];
  }
}

/ //----Comment this out if you want the 10s digit to display zeros---- if (c10 == 0 && i == 1) { // If count is less then 10 set all 10s digit segments off segA = segB = segC = segD = segE = segF = segG = CRGB::Black; }/ //-------------------------------------------------------------------

} }//end setSegments`