// нарисовать дату календаря #273
Unanswered
Libra27
asked this question in
Задавайте вопросы
Replies: 1 comment
-
Что-то бред какой-то, а не код... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Всем привет. Есть ли простой способ изменить формат даты с текущего ДД/ММ/ГГГГ на ГГГГ/ММ/ДД? Если нет простого способа, то помогите разобраться, где нужно копаться в коде, и я попробую изменить его сам. Я уже изменил часть кода, чтобы отображать статический текст вместо эффекта «Лампа», потому что мне нужно было показать номер телефона внизу и текст вверху, с датой и временем на нем, и дополнительную информацию с прокручивающимся текстом. Вот код:
void fillColorProcedure() {
if (loadingFlag) {
loadingFlag = false;
}
uint8_t effectBrightness = getBrightnessCalculated(globalBrightness, getEffectContrastValue(thisMode));
uint8_t bright = isAlarming && !isAlarmStopped
? dawnBrightness
: (specialMode ? specialBrightness : effectBrightness);
// Draw "8(0)"
int x_center = 0;
int y_center = 0;
byte shape0[17] = {
0b01110, 0b10001, 0b10001, 0b01110, 0b10001, 0b10001, 0b01110,
};
int segment0 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment0 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment0 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape0[i] & (1 << j)) {
leds[index] = CRGB::LawnGreen;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "6"
x_center = 0;
y_center = 6;
byte shape1[15] = {
0b01110, 0b10001, 0b10001, 0b01111, 0b0001, 0b0010, 0b01100,
};
int segment1 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment1 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment1 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape1[i] & (1 << j)) {
leds[index] = CRGB::OrangeRed;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "8(1)"
x_center = 0;
y_center = 11;
byte shape2[17] = {
0b01110, 0b10001, 0b10001, 0b01110, 0b10001, 0b10001, 0b01110,
};
int segment2 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment2 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment2 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape2[i] & (1 << j)) {
leds[index] = CRGB::Red;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "3(0)"
x_center = 16;
y_center = 0;
byte shape3[14] = {
0b01110, 0b10001, 0b10000, 0b01000, 0b00100, 0b01000, 0b11111,
};
int segment3 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment3 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment3 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
// Draw "3(1)"
x_center = 16;
y_center = 6;
byte shape4[14] = {
0b01110, 0b10001, 0b10000, 0b01000, 0b00100, 0b01000, 0b11111,
};
int segment4 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment4 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment4 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
// Draw "3(2)"
x_center = 16;
y_center = 11;
byte shape5[14] = {
0b01110, 0b10001, 0b10000, 0b01000, 0b00100, 0b01000, 0b11111,
};
int segment5 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment5 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment5 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
// Draw "1"
x_center = 0;
y_center = 0;
byte shape6[10] = {
0b01110, 0b00100, 0b00100, 0b00100, 0b00100, 0b00110, 0b00100,
};
int segment6 = 1;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment6 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment6 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
// Draw "3(3)"
x_center = 0;
y_center = 5;
byte shape7[14] = {
0b01110, 0b10001, 0b10000, 0b01000, 0b00100, 0b01000, 0b11111,
};
int segment7 = 1;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment7 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment7 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
// Draw "8(2)"
x_center = 0;
y_center = 10;
byte shape8[17] = {
0b01110, 0b10001, 0b10001, 0b01110, 0b10001, 0b10001, 0b01110,
};
int segment8 = 1;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment8 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment8 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape8[i] & (1 << j)) {
leds[index] = CRGB::Red;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "R"
x_center = 57;
y_center = 4;
byte shape9[18] = {
0b10001, 0b01001, 0b00101, 0b01111, 0b10001, 0b10001, 0b01111,
};
int segment9 = 1;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment9 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment9 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape9[i] & (1 << j)) {
leds[index] = CRGB::Honeydew;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "E"
x_center = 57;
y_center = 9;
byte shape10[18] = {
0b11111, 0b00001, 0b00001, 0b01111, 0b00001, 0b00001, 0b11111,
};
int segment10 = 1;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment10 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment10 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape10[i] & (1 << j)) {
leds[index] = CRGB::CadetBlue;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "M(0)"
x_center = 57;
y_center = 14;
byte shape11[8] = {
0b01, 0b01, 0b01, 0b01, 0b01, 0b11, 0b01,
};
int segment11 = 1;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 2; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment11 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment11 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape11[i] & (1 << j)) {
leds[index] = CRGB::Honeydew;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "M(1)"
x_center = 73;
y_center = 0;
byte shape12[10] = {
0b100, 0b100, 0b100, 0b101, 0b101, 0b110, 0b100,
};
int segment12 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 3; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment12 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment12 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape12[i] & (1 << j)) {
leds[index] = CRGB::Honeydew;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "O"
x_center = 73;
y_center = 3;
byte shape13[16] = {
0b01110, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b01110,
};
int segment13 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment13 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment13 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape13[i] & (1 << j)) {
leds[index] = CRGB::CadetBlue;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "N"
x_center = 73;
y_center = 8;
byte shape14[17] = {
0b10001, 0b10001, 0b11001, 0b10101, 0b10011, 0b10001, 0b10001,
};
int segment14 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment14 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment14 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape14[i] & (1 << j)) {
leds[index] = CRGB::Honeydew;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "T(0)"
x_center = 73;
y_center = 13;
byte shape15[9] = {
0b100, 0b100, 0b100, 0b100, 0b100, 0b100, 0b111,
};
int segment15 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 3; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment15 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment15 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape15[i] & (1 << j)) {
leds[index] = CRGB::CadetBlue;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "T(1)"
x_center = 62;
y_center = 0;
byte shape16[2] = {
0b00, 0b11,
};
int segment16 = 0;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment16 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment16 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape16[i] & (1 << j)) {
leds[index] = CRGB::CadetBlue;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "A"
x_center = 57;
y_center = 2;
byte shape17[18] = {
0b10001, 0b10001, 0b11111, 0b10001, 0b10001, 0b10001, 0b01110,
};
int segment17 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment17 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment17 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape17[i] & (1 << j)) {
leds[index] = CRGB::Honeydew;
} else {
leds[index] = CRGB::Black;
}
}
}
// Draw "S"
x_center = 57;
y_center = 7;
byte shape18[15] = {
0b01111, 0b10000, 0b10000, 0b01110, 0b00001, 0b00001, 0b11110,
};
int segment18 = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 5; j++) {
int x = i + x_center;
int y = j + y_center;
int index = ((segment18 % 3 == 0) ? ((x % 2 == 1) ? (x * 16 + 15 - y) : (x * 16 + y)) :
(segment18 % 3 == 1) ? ((x % 2 == 1) ? (x * 16 + 15 - y + 512) : (x * 16 + y + 512)) :
((x % 2 == 1) ? (x * 16 + 15 - y + 1024) : (x * 16 + y + 1024)));
if(shape18[i] & (1 << j)) {
leds[index] = CRGB::CadetBlue;
} else {
leds[index] = CRGB::Black;
}
}
}
}
Все проверено и работает, матрица 48х32 из шести сегментов 16х16 соединенных вертикальными змейками, точка соединения: левый-нижний. Может кому понадобится.
Beta Was this translation helpful? Give feedback.
All reactions