923 lines
34 KiB
C++
923 lines
34 KiB
C++
|
// -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
||
|
//
|
||
|
// This code is public domain
|
||
|
// (but note, once linked against the led-matrix library, this is
|
||
|
// covered by the GPL v2)
|
||
|
//
|
||
|
// This is a grab-bag of various demos and not very readable.
|
||
|
#include "led-matrix-c.h"
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
#include <iostream>
|
||
|
#include <ctime>
|
||
|
using namespace std;
|
||
|
|
||
|
uint8_t color_num[3] = {128, 128, 128};
|
||
|
uint8_t color_hand[3] = {0, 0, 0};
|
||
|
uint8_t color_colon[3] = {0, 0, 0};
|
||
|
uint8_t color_back[3] = {128, 128, 128};
|
||
|
int time_frame = 1000; //ms
|
||
|
int time_pausa = 500; //ms
|
||
|
|
||
|
int seconds, minutes, hours;
|
||
|
struct RGBLedMatrixOptions options;
|
||
|
struct RGBLedRuntimeOptions rt_options;
|
||
|
struct RGBLedMatrix *matrix;
|
||
|
struct LedCanvas *offscreen_canvas;
|
||
|
|
||
|
int number_select = 3;
|
||
|
int width_number[4] = { 5, 4, 3, 6};
|
||
|
int height_number[4] = { 7, 7, 5, 10};
|
||
|
int ini_point_x[4] = {13, 16, 19, 7};
|
||
|
int ini_point_y[4] = {52, 52, 52, 27};
|
||
|
int width_points[4] = { 3, 3, 3, 6};
|
||
|
|
||
|
uint8_t numA[10][7] = {{0b01110,
|
||
|
0b10001,
|
||
|
0b10011,
|
||
|
0b10101,
|
||
|
0b11001,
|
||
|
0b10001,
|
||
|
0b01110},
|
||
|
{0b00100,
|
||
|
0b01100,
|
||
|
0b10100,
|
||
|
0b00100,
|
||
|
0b00100,
|
||
|
0b00100,
|
||
|
0b11111},
|
||
|
{0b11110,
|
||
|
0b00001,
|
||
|
0b00001,
|
||
|
0b00010,
|
||
|
0b00100,
|
||
|
0b01000,
|
||
|
0b11111},
|
||
|
{0b11110,
|
||
|
0b00001,
|
||
|
0b00001,
|
||
|
0b01110,
|
||
|
0b00001,
|
||
|
0b00001,
|
||
|
0b11110},
|
||
|
{0b10001,
|
||
|
0b10001,
|
||
|
0b10001,
|
||
|
0b11111,
|
||
|
0b00001,
|
||
|
0b00001,
|
||
|
0b00001},
|
||
|
{0b11111,
|
||
|
0b10000,
|
||
|
0b10000,
|
||
|
0b11110,
|
||
|
0b00001,
|
||
|
0b00001,
|
||
|
0b11110},
|
||
|
{0b01110,
|
||
|
0b10000,
|
||
|
0b10000,
|
||
|
0b11110,
|
||
|
0b10001,
|
||
|
0b10001,
|
||
|
0b11110},
|
||
|
{0b11111,
|
||
|
0b00001,
|
||
|
0b00001,
|
||
|
0b00010,
|
||
|
0b00100,
|
||
|
0b00100,
|
||
|
0b00100},
|
||
|
{0b01110,
|
||
|
0b10001,
|
||
|
0b10001,
|
||
|
0b01110,
|
||
|
0b10001,
|
||
|
0b10001,
|
||
|
0b01110},
|
||
|
{0b01110,
|
||
|
0b10001,
|
||
|
0b10001,
|
||
|
0b01111,
|
||
|
0b00001,
|
||
|
0b10001,
|
||
|
0b01110}};
|
||
|
|
||
|
uint8_t numB[10][7] = {{0b0110,
|
||
|
0b1001,
|
||
|
0b1001,
|
||
|
0b1001,
|
||
|
0b1001,
|
||
|
0b1001,
|
||
|
0b0110},
|
||
|
{0b0001,
|
||
|
0b0011,
|
||
|
0b0101,
|
||
|
0b1001,
|
||
|
0b0001,
|
||
|
0b0001,
|
||
|
0b0001},
|
||
|
{0b0110,
|
||
|
0b1001,
|
||
|
0b0001,
|
||
|
0b0010,
|
||
|
0b0100,
|
||
|
0b1000,
|
||
|
0b1111},
|
||
|
{0b0110,
|
||
|
0b1001,
|
||
|
0b0001,
|
||
|
0b0010,
|
||
|
0b0001,
|
||
|
0b1001,
|
||
|
0b0110},
|
||
|
{0b0011,
|
||
|
0b0101,
|
||
|
0b1001,
|
||
|
0b1111,
|
||
|
0b0001,
|
||
|
0b0001,
|
||
|
0b0001},
|
||
|
{0b1111,
|
||
|
0b1000,
|
||
|
0b1000,
|
||
|
0b1110,
|
||
|
0b0001,
|
||
|
0b1001,
|
||
|
0b0110},
|
||
|
{0b0110,
|
||
|
0b1000,
|
||
|
0b1000,
|
||
|
0b1110,
|
||
|
0b1001,
|
||
|
0b1001,
|
||
|
0b0110},
|
||
|
{0b1111,
|
||
|
0b0001,
|
||
|
0b0001,
|
||
|
0b0010,
|
||
|
0b0100,
|
||
|
0b1000,
|
||
|
0b1000},
|
||
|
{0b0110,
|
||
|
0b1001,
|
||
|
0b1001,
|
||
|
0b0110,
|
||
|
0b1001,
|
||
|
0b1001,
|
||
|
0b0110},
|
||
|
{0b0110,
|
||
|
0b1001,
|
||
|
0b1001,
|
||
|
0b0111,
|
||
|
0b0001,
|
||
|
0b0001,
|
||
|
0b0110}};
|
||
|
|
||
|
uint8_t numC[10][5] = {{0b111,
|
||
|
0b101,
|
||
|
0b101,
|
||
|
0b101,
|
||
|
0b111},
|
||
|
{0b001,
|
||
|
0b011,
|
||
|
0b101,
|
||
|
0b001,
|
||
|
0b001},
|
||
|
{0b111,
|
||
|
0b001,
|
||
|
0b111,
|
||
|
0b100,
|
||
|
0b111},
|
||
|
{0b111,
|
||
|
0b001,
|
||
|
0b111,
|
||
|
0b001,
|
||
|
0b111},
|
||
|
{0b101,
|
||
|
0b101,
|
||
|
0b111,
|
||
|
0b001,
|
||
|
0b001},
|
||
|
{0b111,
|
||
|
0b100,
|
||
|
0b111,
|
||
|
0b001,
|
||
|
0b111},
|
||
|
{0b100,
|
||
|
0b100,
|
||
|
0b111,
|
||
|
0b101,
|
||
|
0b111},
|
||
|
{0b111,
|
||
|
0b001,
|
||
|
0b001,
|
||
|
0b001,
|
||
|
0b001},
|
||
|
{0b111,
|
||
|
0b101,
|
||
|
0b111,
|
||
|
0b101,
|
||
|
0b111},
|
||
|
{0b111,
|
||
|
0b101,
|
||
|
0b111,
|
||
|
0b001,
|
||
|
0b001}};
|
||
|
|
||
|
uint8_t numD[10][10] = {{0b011110,
|
||
|
0b111111,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b111111,
|
||
|
0b011110},
|
||
|
{0b111100,
|
||
|
0b111100,
|
||
|
0b001100,
|
||
|
0b001100,
|
||
|
0b001100,
|
||
|
0b001100,
|
||
|
0b001100,
|
||
|
0b001100,
|
||
|
0b111111,
|
||
|
0b111111},
|
||
|
{0b111110,
|
||
|
0b111111,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b011111,
|
||
|
0b111111,
|
||
|
0b110000,
|
||
|
0b110000,
|
||
|
0b111111,
|
||
|
0b111111},
|
||
|
{0b111110,
|
||
|
0b111111,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b011110,
|
||
|
0b011110,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b111111,
|
||
|
0b111110},
|
||
|
{0b110011,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b111111,
|
||
|
0b111111,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b000011},
|
||
|
{0b111111,
|
||
|
0b111111,
|
||
|
0b110000,
|
||
|
0b110000,
|
||
|
0b111110,
|
||
|
0b111111,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b111111,
|
||
|
0b111110},
|
||
|
{0b011111,
|
||
|
0b111111,
|
||
|
0b110000,
|
||
|
0b110000,
|
||
|
0b111110,
|
||
|
0b111111,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b111111,
|
||
|
0b011110},
|
||
|
{0b111111,
|
||
|
0b111111,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b000011},
|
||
|
{0b011110,
|
||
|
0b111111,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b011110,
|
||
|
0b011110,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b111111,
|
||
|
0b011110},
|
||
|
{0b011110,
|
||
|
0b111111,
|
||
|
0b110011,
|
||
|
0b110011,
|
||
|
0b111111,
|
||
|
0b011111,
|
||
|
0b000011,
|
||
|
0b000011,
|
||
|
0b111111,
|
||
|
0b111110}};
|
||
|
|
||
|
uint8_t points[7] = {0b000,
|
||
|
0b000,
|
||
|
0b010,
|
||
|
0b000,
|
||
|
0b010,
|
||
|
0b000,
|
||
|
0b000};
|
||
|
|
||
|
uint8_t pointsC[5] = {0b000,
|
||
|
0b010,
|
||
|
0b000,
|
||
|
0b010,
|
||
|
0b000};
|
||
|
|
||
|
uint8_t pointsD[10] = {0b000000,
|
||
|
0b000000,
|
||
|
0b001100,
|
||
|
0b001100,
|
||
|
0b000000,
|
||
|
0b000000,
|
||
|
0b001100,
|
||
|
0b001100,
|
||
|
0b000000,
|
||
|
0b000000};
|
||
|
|
||
|
uint32_t Hand_0[46] = {0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000000001100000000000,
|
||
|
0b00000000000110011110011000000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100110,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000000000011110111101111,
|
||
|
0b00000011111111101110111101111,
|
||
|
0b00000111111111110110111101111,
|
||
|
0b00000111111111110110111101111,
|
||
|
0b00000111111111101110111101111,
|
||
|
0b00000111100000011110011001111,
|
||
|
0b00000111101111101101100110110,
|
||
|
0b00000111101111110011111111001,
|
||
|
0b00000111101111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000011111111111111111111111,
|
||
|
0b00000001111111111111111111110,
|
||
|
0b00000000111111111111111111110,
|
||
|
0b00000000011111111111111111110,
|
||
|
0b00000000001111111111111111100,
|
||
|
0b00000000000111111111111111100,
|
||
|
0b00000000000011111111111111100,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000};
|
||
|
|
||
|
uint32_t Hand_1[46] = {0b00000000000000000000000000000,
|
||
|
0b00000000000000000000000000000,
|
||
|
0b00000000000110000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111000000000000000,
|
||
|
0b00000000001111001100000000000,
|
||
|
0b00000000001111011110011000000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100110,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000000000011110111101111,
|
||
|
0b00000011111111101110111101111,
|
||
|
0b00000111111111110110111101111,
|
||
|
0b00000111111111110110111101111,
|
||
|
0b00000111111111101110111101111,
|
||
|
0b00000111100000011110011001111,
|
||
|
0b00000111101111101101100110110,
|
||
|
0b00000111101111110011111111001,
|
||
|
0b00000111101111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000011111111111111111111111,
|
||
|
0b00000001111111111111111111110,
|
||
|
0b00000000111111111111111111110,
|
||
|
0b00000000011111111111111111110,
|
||
|
0b00000000001111111111111111100,
|
||
|
0b00000000000111111111111111100,
|
||
|
0b00000000000011111111111111100,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000};
|
||
|
|
||
|
uint32_t Hand_2[46] = {0b00000000000000001100000000000,
|
||
|
0b00000000000000011110000000000,
|
||
|
0b00000000000110011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110011000000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100110,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000000000011110111101111,
|
||
|
0b00000011111111101110111101111,
|
||
|
0b00000111111111110110111101111,
|
||
|
0b00000111111111110110111101111,
|
||
|
0b00000111111111101110111101111,
|
||
|
0b00000111100000011110011001111,
|
||
|
0b00000111101111111111100110110,
|
||
|
0b00000111101111111111111111001,
|
||
|
0b00000111101111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000011111111111111111111111,
|
||
|
0b00000001111111111111111111110,
|
||
|
0b00000000111111111111111111110,
|
||
|
0b00000000011111111111111111110,
|
||
|
0b00000000001111111111111111100,
|
||
|
0b00000000000111111111111111100,
|
||
|
0b00000000000011111111111111100,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000};
|
||
|
|
||
|
uint32_t Hand_3[46] = {0b00000000000000001100000000000,
|
||
|
0b00000000000000011110000000000,
|
||
|
0b00000000000110011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110000000000,
|
||
|
0b00000000001111011110011000000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100110,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111111110111101111,
|
||
|
0b00000000001111111110111101111,
|
||
|
0b01110000001111111110111101111,
|
||
|
0b11111000001111111110111101111,
|
||
|
0b11111100001111111110111101111,
|
||
|
0b11111110001111111111011001111,
|
||
|
0b01111111001111111111100110110,
|
||
|
0b00111111101111111111111111001,
|
||
|
0b00011111111111111111111111111,
|
||
|
0b00001111111111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000011111111111111111111111,
|
||
|
0b00000001111111111111111111110,
|
||
|
0b00000000111111111111111111110,
|
||
|
0b00000000011111111111111111110,
|
||
|
0b00000000001111111111111111100,
|
||
|
0b00000000000111111111111111100,
|
||
|
0b00000000000011111111111111100,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000};
|
||
|
|
||
|
uint32_t Hand_4[46] = {0b00000000000000001100000000000,
|
||
|
0b00000000000000011110000000000,
|
||
|
0b00000000000110011110000000000,
|
||
|
0b00000000001111011110011000000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100110,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000000000011111111101111,
|
||
|
0b00000011111111101111111111111,
|
||
|
0b00000111111111110111111111111,
|
||
|
0b00000111111111110111111111111,
|
||
|
0b00000111111111101111111111111,
|
||
|
0b00000111100000011111111111111,
|
||
|
0b00000111101111111111111111111,
|
||
|
0b00000111101111111111111111111,
|
||
|
0b00000111101111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000011111111111111111111111,
|
||
|
0b00000001111111111111111111110,
|
||
|
0b00000000111111111111111111110,
|
||
|
0b00000000011111111111111111110,
|
||
|
0b00000000001111111111111111100,
|
||
|
0b00000000000111111111111111100,
|
||
|
0b00000000000011111111111111100,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000};
|
||
|
|
||
|
uint32_t Hand_5[46] = {0b00000000000000001100000000000,
|
||
|
0b00000000000000011110000000000,
|
||
|
0b00000000000110011110000000000,
|
||
|
0b00000000001111011110011000000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100000,
|
||
|
0b00000000001111011110111100110,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111011110111101111,
|
||
|
0b00000000001111111111111101111,
|
||
|
0b00000000001111111111111111111,
|
||
|
0b01110000001111111111111111111,
|
||
|
0b11111000001111111111111111111,
|
||
|
0b11111100001111111111111111111,
|
||
|
0b11111110001111111111111111111,
|
||
|
0b01111111001111111111111111111,
|
||
|
0b00111111101111111111111111111,
|
||
|
0b00011111111111111111111111111,
|
||
|
0b00001111111111111111111111111,
|
||
|
0b00000111111111111111111111111,
|
||
|
0b00000011111111111111111111111,
|
||
|
0b00000001111111111111111111110,
|
||
|
0b00000000111111111111111111110,
|
||
|
0b00000000011111111111111111110,
|
||
|
0b00000000001111111111111111100,
|
||
|
0b00000000000111111111111111100,
|
||
|
0b00000000000011111111111111100,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000001111111111111000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000,
|
||
|
0b00000000000000111111111110000};
|
||
|
|
||
|
uint64_t Hand_Colon[29] = { 0b0000000000000000000000000000000000000000000000,
|
||
|
0b0000000000000000000000000000000000000000000000,
|
||
|
0b0000000000000000000000000000000000000000000000,
|
||
|
0b0000000000000000000000000000000000000000000000,
|
||
|
0b0000000000000000000000000000000000000000000000,
|
||
|
0b0000000000000000000000000000000000000000000000,
|
||
|
0b0000000000000000000000000000000000000000000000,
|
||
|
0b0000000000011111111111000000000000000000000000,
|
||
|
0b0000000000111111111111100000000000000000000000,
|
||
|
0b0000000001111111111111100000000000000000000000,
|
||
|
0b0000000011111111111111111111111111111111111000,
|
||
|
0b0000000111111111111111111111111111111111111100,
|
||
|
0b0000001111111111111111111111111111111111111100,
|
||
|
0b0000111111111111111111111111111111111111111000,
|
||
|
0b1111111111111111111111110000000000000000000000,
|
||
|
0b1111111111111111111111111111111111111111111110,
|
||
|
0b1111111111111111111111111111111111111111111111,
|
||
|
0b1111111111111111111111111111111111111111111111,
|
||
|
0b1111111111111111111111111111111111111111111110,
|
||
|
0b1111111111111111111111110000000000000000000000,
|
||
|
0b1111111111111111111111111111100000000000000000,
|
||
|
0b1111111111111111111111111111110000000000000000,
|
||
|
0b1111111111111111111111111111110000000000000000,
|
||
|
0b1111111111111111111111111111100000000000000000,
|
||
|
0b1111111111111111111111100000000000000000000000,
|
||
|
0b0000111111111111111111111100000000000000000000,
|
||
|
0b0000001111111111111111111110000000000000000000,
|
||
|
0b0000000001111111111111111110000000000000000000,
|
||
|
0b0000000000001111111111111100000000000000000000};
|
||
|
|
||
|
uint8_t screen_red[64][64];
|
||
|
uint8_t screen_green[64][64];
|
||
|
uint8_t screen_blue[64][64];
|
||
|
|
||
|
void screen_write(int x, int y, int red, int green, int blue)
|
||
|
{
|
||
|
screen_red[x][y] = red;
|
||
|
screen_green[x][y]= green;
|
||
|
screen_blue[x][y]= blue;
|
||
|
}
|
||
|
|
||
|
void screen_fill(int red, int green, int blue)
|
||
|
{
|
||
|
for (int y = 0; y < 64; ++y)
|
||
|
for (int x = 0; x < 64; ++x) screen_write(x, y, red, green, blue);
|
||
|
}
|
||
|
|
||
|
|
||
|
void write_hand(int hand_num, char orientation)
|
||
|
{
|
||
|
uint32_t *hand_temp[6] = {Hand_0, Hand_1 , Hand_2, Hand_3, Hand_4, Hand_5};
|
||
|
for (int y = 0; y < 46; ++y)
|
||
|
for (int x = 0; x < 29; ++x)
|
||
|
{
|
||
|
if ((orientation=='R')&&(1&(hand_temp[hand_num][45-y]>>x))) screen_write(2+x, y, color_hand[0], color_hand[1], color_hand[2]);
|
||
|
else if ((orientation=='L')&&(1&(hand_temp[hand_num][45-y]>>(28-x)))) screen_write(33+x, y, color_hand[0], color_hand[1], color_hand[2]);
|
||
|
else if ((orientation=='C')&&(1&(hand_temp[hand_num][45-y]>>x))) screen_write(22+x, y, color_hand[0], color_hand[1], color_hand[2]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void refresh()
|
||
|
{
|
||
|
//offscreen_canvas = led_matrix_create_offscreen_canvas(matrix);
|
||
|
for (int y = 0; y < 64; ++y)
|
||
|
//for (int x = 0; x < 64; ++x) led_canvas_set_pixel(offscreen_canvas, 63-x, y, screen_red[x][y], screen_green[x][y], screen_blue[x][y]);
|
||
|
for (int x = 0; x < 64; ++x) led_canvas_set_pixel(offscreen_canvas, y, x, screen_red[x][y], screen_green[x][y], screen_blue[x][y]);
|
||
|
offscreen_canvas = led_matrix_swap_on_vsync(matrix, offscreen_canvas);
|
||
|
screen_fill(color_back[0], color_back[1], color_back[2]);
|
||
|
}
|
||
|
|
||
|
int p0 = ini_point_x[number_select];
|
||
|
int p1 = p0 + width_number[number_select] + 1;
|
||
|
int p2 = p1 + width_number[number_select];
|
||
|
int p3 = p2 + width_points[number_select];
|
||
|
int p4 = p3 + width_number[number_select] + 1;
|
||
|
int p5 = p4 + width_number[number_select];
|
||
|
int p6 = p5 + width_points[number_select];
|
||
|
int p7 = p6 + width_number[number_select] + 1;
|
||
|
|
||
|
int positions[8] = {p0, p1, p2, p3, p4, p5, p6, p7};
|
||
|
|
||
|
void write_number(int num, int pos)
|
||
|
{
|
||
|
uint8_t *num_temp = 0;
|
||
|
if (number_select==0) num_temp = numA[num];
|
||
|
else if (number_select==1) num_temp = numB[num];
|
||
|
else if (number_select==2) num_temp = numC[num];
|
||
|
else if (number_select==3) num_temp = numD[num];
|
||
|
|
||
|
for (int y = 0; y < height_number[number_select]; ++y)
|
||
|
for (int x = 0; x < width_number[number_select]; ++x) if (1&(num_temp[height_number[number_select]-1-y]>>(width_number[number_select]-1-x))) screen_write(x + positions[pos] , y + ini_point_y[number_select], color_num[0], color_num[1], color_num[2]);
|
||
|
}
|
||
|
|
||
|
void write_points(int pos)
|
||
|
{
|
||
|
uint8_t *points_temp = 0;
|
||
|
if (number_select==0) points_temp = points;
|
||
|
else if (number_select==1) points_temp = points;
|
||
|
else if (number_select==2) points_temp = pointsC;
|
||
|
else if (number_select==3) points_temp = pointsD;
|
||
|
|
||
|
for (int y = 0; y < height_number[number_select]; ++y)
|
||
|
for (int x = 0; x < width_points[number_select]; ++x) if (1&(points_temp[height_number[number_select]-1-y]>>x)) screen_write(x + positions[pos], y + ini_point_y[number_select], color_num[0], color_num[1], color_num[2]);
|
||
|
}
|
||
|
|
||
|
void write_clock(int hour, int minute, int second)
|
||
|
{
|
||
|
write_number(hour/10, 0);
|
||
|
write_number(hour%10, 1);
|
||
|
write_points(2);
|
||
|
write_number(minute/10, 3);
|
||
|
write_number(minute%10, 4);
|
||
|
write_points(5);
|
||
|
write_number(second/10, 6);
|
||
|
write_number(second%10, 7);
|
||
|
}
|
||
|
|
||
|
void write_hands(int hands_num)
|
||
|
{
|
||
|
//write_clock(hours, minutes, seconds);
|
||
|
if(hands_num>0)
|
||
|
{
|
||
|
if(((hands_num%10)<10)&&(hands_num<10))
|
||
|
{
|
||
|
if((hands_num%10)<6)
|
||
|
{
|
||
|
write_hand(hands_num/10, 'R');
|
||
|
write_hand(hands_num%10, 'L');
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
write_hand(5, 'R');
|
||
|
write_hand(hands_num-5, 'L');
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
write_hand(hands_num/10, 'C');
|
||
|
refresh();
|
||
|
usleep(time_frame*1000);
|
||
|
//write_clock(hours, minutes, seconds);
|
||
|
refresh();
|
||
|
usleep(time_pausa*1000);
|
||
|
//write_clock(hours, minutes, seconds);
|
||
|
if((hands_num%10)<6)
|
||
|
{
|
||
|
write_hand(hands_num%10, 'C');
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
write_hand(5, 'R');
|
||
|
write_hand(hands_num%10-5, 'L');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
write_hand(0, 'R');
|
||
|
write_hand(0, 'L');
|
||
|
}
|
||
|
refresh();
|
||
|
usleep(time_frame*1000);
|
||
|
}
|
||
|
|
||
|
void write_colon(int des)
|
||
|
{
|
||
|
/*for (int y = 0; y < 29; ++y)
|
||
|
for (int x = 0; x < 46; ++x) if (1&(Hand_Colon[28-y]>>(45-x))) screen_write(x, y + 11, color_colon[0], color_colon[1], color_colon[2]);*/
|
||
|
if (des<18)
|
||
|
{
|
||
|
/*for (int y = 0; y < 64; ++y)
|
||
|
for (int x = 45-des; x < 46; ++x) screen_write(x-(45-des), y, 0, 0, 0); */
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
des = des-18;
|
||
|
/*for (int y = 0; y < 64; ++y)
|
||
|
for (int x = 0; x < (des + 19); ++x) if(x<64) screen_write(x, y, 0, 0, 0); */
|
||
|
if (des<46)
|
||
|
{
|
||
|
for (int y = 0; y < 29; ++y)
|
||
|
for (int x = 45-des; x < 46; ++x) if (1&(Hand_Colon[28-y]>>(45-x))) screen_write(x-(45-des), y + 11, color_colon[0], color_colon[1], color_colon[2]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void write_des(int des)
|
||
|
{
|
||
|
for (int y = 0; y < 64; ++y)
|
||
|
for (int x = 0; x < des + 1; ++x) if(x<64) screen_write(x, y, 0, 0, 0); ;
|
||
|
}
|
||
|
|
||
|
void colon_animation()
|
||
|
{
|
||
|
//write_clock(hours, minutes, seconds);
|
||
|
refresh();
|
||
|
usleep(time_pausa*1000);
|
||
|
//uint8_t color_back_temp[3] = {color_back[0], color_back[1], color_back[2]};
|
||
|
//for(int i=0; i<3; i++) color_back[i] = 0;
|
||
|
for(int i=0; i<64; i++)
|
||
|
{
|
||
|
write_colon(i);
|
||
|
//write_clock(hours, minutes, seconds);
|
||
|
refresh();
|
||
|
usleep(10*1000);
|
||
|
}
|
||
|
usleep(time_frame*1000);
|
||
|
//for(int i=0; i<3; i++) color_back[i] = color_back_temp[i];
|
||
|
//write_clock(hours, minutes, seconds);
|
||
|
refresh();
|
||
|
usleep(time_pausa*1000);
|
||
|
}
|
||
|
|
||
|
void hour_animation()
|
||
|
{
|
||
|
write_clock(hours, minutes, seconds);
|
||
|
refresh();
|
||
|
usleep(time_pausa*1000);
|
||
|
//uint8_t color_back_temp[3] = {color_back[0], color_back[1], color_back[2]};
|
||
|
//for(int i=0; i<3; i++) color_back[i] = 0;
|
||
|
for(int i=0; i<64; i++)
|
||
|
{
|
||
|
write_des(i);
|
||
|
write_clock(hours, minutes, seconds);
|
||
|
refresh();
|
||
|
usleep(10*1000);
|
||
|
}
|
||
|
usleep(time_frame*1000);
|
||
|
//for(int i=0; i<3; i++) color_back[i] = color_back_temp[i];
|
||
|
write_clock(hours, minutes, seconds);
|
||
|
refresh();
|
||
|
//usleep(time_pausa*1000);
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
int width, height;
|
||
|
memset(&options, 0, sizeof(options));
|
||
|
memset(&rt_options, 0, sizeof(rt_options));
|
||
|
options.rows = 64;
|
||
|
options.cols = 64;
|
||
|
options.chain_length = 1;
|
||
|
options.hardware_mapping = "adafruit-hat-pwm"; // or e.g. "adafruit-hat"
|
||
|
options.pwm_lsb_nanoseconds = 100;
|
||
|
options.pwm_bits = 8;
|
||
|
options.limit_refresh_rate_hz = 100;
|
||
|
rt_options.gpio_slowdown = 2;
|
||
|
rt_options.drop_privileges = 1;
|
||
|
/* This supports all the led commandline options. Try --led-help */
|
||
|
|
||
|
matrix = led_matrix_create_from_options_and_rt_options(&options, &rt_options);
|
||
|
if (matrix == NULL)
|
||
|
return 1;
|
||
|
|
||
|
offscreen_canvas = led_matrix_create_offscreen_canvas(matrix);
|
||
|
led_canvas_get_size(offscreen_canvas, &width, &height);
|
||
|
|
||
|
fprintf(stderr, "Size: %dx%d. Hardware gpio mapping: %s\n",
|
||
|
width, height, options.hardware_mapping);
|
||
|
screen_fill(color_back[0], color_back[1], color_back[2]);
|
||
|
|
||
|
while (1)
|
||
|
{
|
||
|
// current date/time based on current system
|
||
|
time_t now = time(0);
|
||
|
|
||
|
//cout << "number of sec since January 1,1970 is:: " << now << endl;
|
||
|
|
||
|
tm *ltm = localtime(&now);
|
||
|
hours = ltm->tm_hour;
|
||
|
minutes = ltm->tm_min;
|
||
|
seconds = ltm->tm_sec;
|
||
|
//write_clock(hours, minutes, seconds);
|
||
|
//refresh();
|
||
|
|
||
|
hour_animation();
|
||
|
//usleep(time_pausa*1000);
|
||
|
write_hands(hours);
|
||
|
colon_animation();
|
||
|
write_hands(minutes);
|
||
|
colon_animation();
|
||
|
write_hands(seconds);
|
||
|
//usleep(time_pausa*1000);
|
||
|
}
|
||
|
led_matrix_delete(matrix);
|
||
|
}
|