UKHeliBob:
That's a very short line
No. It's not a short line.

This is a P10 Display.
Now Length will be 4 Display, Width will be 4 Display.
I Think Now You Might Understand.
UKHeliBob:
That's a very short line
No. It's not a short line.

This is a P10 Display.
Now Length will be 4 Display, Width will be 4 Display.
I Think Now You Might Understand.
I Think Now You Might Understand
When I asked if you knew how to draw a line between 2 points on the display I meant a line of dots as might be used to represent the hands of an analogue clock, not a line of text
What library are you using to control the display ?
UKHeliBob:
When I asked if you knew how to draw a line between 2 points on the display I meant a line of dots as might be used to represent the hands of an analogue clock, not a line of textWhat library are you using to control the display ?
Sorry. I didn't understand that time.
I'm using DMD2 Library.
My Code is Given Below.
// Inserting File Library
#include <SPI.h>
#include <DMD2.h>
#include <NMEAGPS.h>
#include <fonts/Arial_Black_16.h>
// PICK ONE OF THESE PORT ALTERNATIVES
//
// BEST: connect GPS to pins 0 & 1, since you're not using Serial.
// Requires disconnecting pin 0 to upload new sketch over USB.
#define gpsPort Serial // just an alias for Serial
// 2nd BEST: connect GPS to pins 8 & 9 (on an UNO)
//#include <AltSoftSerial.h>
//AltSoftSerial gpsPort
// 3rd BEST:
//#include <NeoSWSerial.h>
//NeoSWSerial gpsPort(3, 4); // RX, TX
// WORST: SoftwareSerial NOT RECOMMENDED
// Defining Constants
#define Length 2
#define Width 1
// Declaration Variable
SoftDMD dmd(Length, Width); // Length x Width
NMEAGPS gps; // parser
void setup()
{
dmd.setBrightness(255);
dmd.selectFont(Arial_Black_16);
dmd.begin();
dmd.clearScreen();
gpsPort.begin(9600);
}
void loop()
{
if (gps.available( gpsPort )) {
gps_fix fix = gps.read();
if (fix.valid.time) {
// UTC_ind_zone_time
char dmdBuff[10];
sprintf_P( dmdBuff, PSTR("%02d:%02d:%02d"),
fix.dateTime.hours, fix.dateTime.minutes, fix.dateTime.seconds );
dmd.drawString(0,1,dmdBuff);
}
}
}
The library appears to have functions to draw shapes and lines
From DMD2.h
void drawLine(int x1, int y1, int x2, int y2, DMDGraphicsMode mode=GRAPHICS_ON);
void drawCircle(unsigned int xCenter, unsigned int yCenter, int radius, DMDGraphicsMode mode=GRAPHICS_ON);
void drawBox(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, DMDGraphicsMode mode=GRAPHICS_ON);
void drawFilledBox(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, DMDGraphicsMode mode=GRAPHICS_ON);
void drawTestPattern(DMDTestPattern pattern);
but before you go any further you need to think about how practical it is to draw an analogue clock on a display with such a limited number of pixels. Sketch out on squared paper how you expect it to look
UKHeliBob:
The library appears to have functions to draw shapes and linesFrom DMD2.h
void drawLine(int x1, int y1, int x2, int y2, DMDGraphicsMode mode=GRAPHICS_ON);
void drawCircle(unsigned int xCenter, unsigned int yCenter, int radius, DMDGraphicsMode mode=GRAPHICS_ON);
void drawBox(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, DMDGraphicsMode mode=GRAPHICS_ON);
void drawFilledBox(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, DMDGraphicsMode mode=GRAPHICS_ON);
void drawTestPattern(DMDTestPattern pattern);
but before you go any further you need to think about how practical it is to draw an analogue clock on a display with such a limited number of pixels. Sketch out on squared paper how you expect it to look
This is my display for analog clock. I think its look great on this big display.
This is my display for analog clock. I think its look great on this big display.
OK. That looks like a more reasonable display to use rather than the one in your previous picture.
The first thing to do is to draw a straight line on the display from say 0, 0 to 10, 10 using the drawLine() function
Over to you
UKHeliBob:
OK. That looks like a more reasonable display to use rather than the one in your previous picture.The first thing to do is to draw a straight line on the display from say 0, 0 to 10, 10 using the drawLine() function
Over to you
I have a Analog Clock Code. It's in Led Matrix Display.
Can I use this program clock options code?
What should be the final code if i add this code Clock Option To My Program?
I was trying this last few days but i can't do it! ![]()
// Comment out if using the non-SPI version of the library
#define SPIWrite
// Include the LedMatrix library
#ifdef SPIWrite
#include <LedMatrixSPI.h>
#else
#include <LedMatrix.h>
#endif
const byte NUM_ROWS = 6; // Number of 8x8 display rows
const byte NUM_COLS = 8; // Number of 8x8 display columns
const byte maxWidth = NUM_COLS * 8; // Maximum display width
const byte maxHeight = NUM_ROWS * 8; // Maximum display height
const double rads = 0.0174532925; // Used for clock demo
/*
Create an LedMarix object
The first parameter is the number of 8x8 dot matrix
rows, the second is the number of columns.
*/
#ifdef SPIWrite
LedMatrixSPI lm = LedMatrixSPI(NUM_ROWS, NUM_COLS);
#else
LedMatrix lm = LedMatrix(NUM_ROWS, NUM_COLS);
#endif
void setup() {
// put your setup code here, to run once:
}
void loop() {
int16_t sHand, mHand, hHand, center;
uint8_t centerX = maxWidth / 2 - 1;
uint8_t centerY = maxHeight / 2 - 1;
// Set the start time
int hour = 1;
int minute = 4;
int second = 40;
// Set the length of each hand
int shLen = 23;
int mhLen = 16;
int hhLen = 10;
// Find the center
if (maxWidth > maxHeight)
center = (maxHeight / 2) - 1;
else
center = (maxWidth / 2) - 1;
// Run the clock for some amount of time
while(1) {
// Calculate the degree each had is pointed
sHand = round((360 * second / 60) - 90);
mHand = round((360 * minute / 60) - 90);
hHand = round((360 * hour / 12) - 90);
lm.clear(); // Clear the LED array, but not the screen
lm.circle(centerX, centerY, center); // Draw the clock
// Draw the 3 hands
lm.line(centerX, centerY, centerX + round(shLen * cos(sHand * rads)), centerY + round(shLen * sin(sHand * rads)));
lm.line(centerX, centerY, centerX + round(mhLen * cos(mHand * rads)), centerY + round(mhLen * sin(mHand * rads)));
lm.line(centerX, centerY, centerX + round(hhLen * cos(hHand * rads)), centerY + round(hhLen * sin(hHand * rads)));
lm.update(); // Update the display
delay(975); // Delay almost a second (leave time for program overhead)
second++; // Increment the seconds
// Reset seconds and increment minutes
if (second > 59) {
second = 0;
minute++;
}
// Reset minutes and increment hours
if (minute > 59) {
minute = 0;
hour++;
}
// Reset hours
if (hour > 11) {
hour = 0;
}
}
}
Sisir_Raihan:
I have a Analog Clock Code. It's in Led Matrix Display.
Can I use this program clock options code?
What should be the final code if i add this code Clock Option To My Program?
I was trying this last few days but i can't do it!// Comment out if using the non-SPI version of the library
#define SPIWrite
// Include the LedMatrix library
#ifdef SPIWrite
#include <LedMatrixSPI.h>
#else
#include <LedMatrix.h>
#endif
const byte NUM_ROWS = 6; // Number of 8x8 display rows
const byte NUM_COLS = 8; // Number of 8x8 display columns
const byte maxWidth = NUM_COLS * 8; // Maximum display width
const byte maxHeight = NUM_ROWS * 8; // Maximum display height
const double rads = 0.0174532925; // Used for clock demo
/*
Create an LedMarix object
The first parameter is the number of 8x8 dot matrix
rows, the second is the number of columns.
*/
#ifdef SPIWrite
LedMatrixSPI lm = LedMatrixSPI(NUM_ROWS, NUM_COLS);
#else
LedMatrix lm = LedMatrix(NUM_ROWS, NUM_COLS);
#endif
void setup() {
// put your setup code here, to run once:
}
void loop() {
int16_t sHand, mHand, hHand, center;
uint8_t centerX = maxWidth / 2 - 1;
uint8_t centerY = maxHeight / 2 - 1;
// Set the start time
int hour = 1;
int minute = 4;
int second = 40;
// Set the length of each hand
int shLen = 23;
int mhLen = 16;
int hhLen = 10;
// Find the center
if (maxWidth > maxHeight)
center = (maxHeight / 2) - 1;
else
center = (maxWidth / 2) - 1;
// Run the clock for some amount of time
while(1) {
// Calculate the degree each had is pointed
sHand = round((360 * second / 60) - 90);
mHand = round((360 * minute / 60) - 90);
hHand = round((360 * hour / 12) - 90);
lm.clear(); // Clear the LED array, but not the screen
lm.circle(centerX, centerY, center); // Draw the clock
// Draw the 3 hands
lm.line(centerX, centerY, centerX + round(shLen * cos(sHand * rads)), centerY + round(shLen * sin(sHand * rads)));
lm.line(centerX, centerY, centerX + round(mhLen * cos(mHand * rads)), centerY + round(mhLen * sin(mHand * rads)));
lm.line(centerX, centerY, centerX + round(hhLen * cos(hHand * rads)), centerY + round(hhLen * sin(hHand * rads)));
lm.update(); // Update the display
delay(975); // Delay almost a second (leave time for program overhead)
second++; // Increment the seconds
// Reset seconds and increment minutes
if (second > 59) {
second = 0;
minute++;
}
// Reset minutes and increment hours
if (minute > 59) {
minute = 0;
hour++;
}
// Reset hours
if (hour > 11) {
hour = 0;
}
}
}
Can Anyone Help me doing this program? ![]()