Яркость панели P10

помогите пожалуйста выставить яркость панели P10 32x16 pix…
Делаю часики себе в гараж на одной панельке матричной одноцветной.
через юсб светится тускло, при подключенном питании чуть ярче, но не настолько ярко как с контроллером типа HD-W02 и ему подобным. Есть много ардуинок нано, контроллер покупать неохота.
есть ощущение какого то косяка с библиотекой dmd, попробовал и закомментировал свои эксперименты) как активировать шим на pin 1 enable панели с 9 пина ардуины?
Помогите дополнить код пожалуйста.

//--------------------------------------------------------------------------------Arduino P10 Digital Clock Demo 2------------------------------------
/*
######################################################################################################################################################

Installation:

Arduino Uno DS1307

A5 ---------> SCL

A4 ---------> SDA

5V ---------> VCC

GND ---------> GND

######################################################################################################################################################

######################################################################################################################################################

DMD.h - Function and support library for the Freetronics DMD, a 512 LED matrix display panel arranged in a 32 x 16 layout.

Copyright (C) 2011 Marc Alexander (info freetronics com)

Installation:

Arduino Uno P10 Panel

13 ---------> S / CLK

11 ---------> R

9 ---------> nOE / OE

8 ---------> L / SCLK

7 ---------> B

6 ---------> A

GND ---------> GND

The P10 panel can still turn on without 5V Power Input if it only uses one panel, but to increase brightness it must be added with 5V Power Input.

5V Power Input must also be used if using more than one P10 Panel.

######################################################################################################################################################
*/

//--------------------------------------------------------------------------------------Wire and RTC Library
#include <Wire.h>
#include “RTClib.h”
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------The SPI, DMD, TimerOne and Font libraries are used.
#include <SPI.h>
#include <DMD.h>
//#include <DMD2.h>
#include <TimerOne.h>
#include “SystemFont5x7C.h” //Flint SystemFont5x7.h или SystemFont5x7C.h
#include “Font_6x14.h” //-> This font only contains numbers from 0-9
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------Configuration P10
#define DISPLAYS_ACROSS 1 //-> Number of P10 panels used, side to side.
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
//--------------------------------------------------------------------------------------

RTC_DS1307 rtc; //-> RTC Declaration

//--------------------------------------------------------------------------------------Variables for time and date
int _day, _month, _year, _hour24, _hour12, _minute, _second, _dtw;
int hr24;
String st;
char nameoftheday[7][12] = {“BOCKPECEHbE”, “яOHEф”, “BTOPHuK”, “CPEфA”, “ЗETBEPу”, “яНTHшЖA”, “CГППюTA”};
char month_name[12][12] = {“01”,“02”, “03”, “04”, “05”, “06”, “07”, “08”, “09”, “10”, “11”, “12”};
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------Variable for Millis
const long interval = 1000; //-> Retrieve time and date data every 1 second
unsigned long previousMillis = 0;

const long interval_for_date = 75; //-> Скорость прокрутки даты бегущей строки (75 стандарт)
unsigned long previousMillis_for_date = 0;
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------Variable to display hours and minutes
char hr_24 [3];
String str_hr_24;
char mn [3];
String str_mn;
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------ScanDMD()
void ScanDMD() {
dmd.scanDisplayBySPI();
}

//--------------------------------------------------------------------------------------setup
//int pwm = 9; // This is the pin that we will use //Flint
void setup() {
Serial.begin(115200);
// dmd.setBrightness(255);
// pinMode(pwm, OUTPUT); // declare the pin to be an output //Flint
// analogWrite(pwm, 150); // medium brightness (50%)

Serial.println(“Arduino RTC DS1307”);
delay(1000);

if (! rtc.begin()) {
Serial.println(“Couldn’t find RTC”);
while (1);
}

if (! rtc.isrunning()) {
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled (Set the time and date based on your computer time and date)
// rtc.adjust(DateTime(F(DATE), F(TIME))); //-> Set the time and date based on your computer time and date. If that doesn’t work, use this line of code outside of “if (! rtc.isrunning())”
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
// following line sets the RTC to the date & time this sketch was compiled (Set the time and date based on your computer time and date)
//rtc.adjust(DateTime(F(DATE), F(TIME))); //-> Set the time and date based on your computer time and date. Use this line of code if it doesn’t work in “if (! rtc.isrunning())”
//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
// If the time and date are successfully set, then deactivate the code line (make the code a comment), then re-upload the code.
// if not done then the time and date will return to the beginning when it was set when arduino is reset or restarted.

Timer1.initialize(1000);
Timer1.attachInterrupt(ScanDMD);
dmd.clearScreen(true);
}
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------loop
void loop() {

//_____________________________________________________millis() to display time
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; //-> save the last time

GetDateTime(); //-> Retrieve time and date data from DS1307

dmd.selectFont(Font_6x14);

//=====================================================Showing the clock in P10
str_hr_24=String(_hour24);
str_hr_24.toCharArray(hr_24,3);

if (_hour24<10) {
  dmd.drawString(0, 0, "0", 1, GRAPHICS_NORMAL);
  dmd.drawString(7, 0, hr_24, 1, GRAPHICS_NORMAL);
}
else {
  dmd.drawString(0, 0, hr_24, 2, GRAPHICS_NORMAL);
}
//=====================================================

//=====================================================Showing ":" in P10
if (_second %2 == 0) {
  dmd.drawFilledBox(15,3,16,4, GRAPHICS_OR);
  dmd.drawFilledBox(15,11,16,12, GRAPHICS_OR);
}
else {
  dmd.drawFilledBox(15,3,16,4, GRAPHICS_NOR);
  dmd.drawFilledBox(15,11,16,12, GRAPHICS_NOR);
}
//=====================================================

//=====================================================Showing minutes in P10
str_mn=String(_minute);
str_mn.toCharArray(mn,3);

if (_minute<10) {
  dmd.drawString(19, 0, "0", 1, GRAPHICS_NORMAL);
  dmd.drawString(26, 0, mn, 1, GRAPHICS_NORMAL);
}
else {
  dmd.drawString(19, 0, mn, 2, GRAPHICS_NORMAL);
}
//=====================================================

//=====================================================Call the scrolling_date() subroutine to display the date.
if (_second==11) { //-> Display the date when seconds equal to 11
  scrolling_date();
}
//=====================================================

}
//_____________________________________________________

}
//--------------------------------------------------------------------------------------

//------------------------------------------------------------------------Subroutine to retrieve or update the time and date from DS1307
void GetDateTime() {
DateTime now = rtc.now();
_day=now.day();
_month=now.month();
_year=now.year();
_hour24=now.hour();
_minute=now.minute();
_second=now.second();
_dtw=now.dayOfTheWeek();

hr24=_hour24;
if (hr24>12) {
_hour12=hr24-12;
}
else if (hr24==0) {
_hour12=12;
}
else {
_hour12=hr24;
}

if (hr24<12) {
st=“AM”;
}
else {
st=“PM”;
}
}
//------------------------------------------------------------------------

//------------------------------------------------------------------------Subroutine to display days, months and years
void scrolling_date() {

dmd.clearScreen(true);
delay(100);

//=====================================================Holds date data to display
String Date = String(nameoftheday[_dtw]) + ", " + String(_day) + “/” + String(month_name[_month-1]) + “/” + String(_year);
char dt[50];
Date.toCharArray(dt,50);
int i=32+10;
int j=strlen(dt)+(strlen(dt)*5);
//=====================================================

dmd.selectFont(SystemFont5x7C); //Flint SystemFont5x7.h

while(1) {
//_____________________________________________________millis() to display time
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; //-> save the last time

  //=====================================================Showing the clock in P10
  str_hr_24=String(_hour24);
  str_hr_24.toCharArray(hr_24,3);

  if (_hour24<10) {
    dmd.drawString(2, 0, "0", 1, GRAPHICS_NORMAL);
    dmd.drawString(8, 0, hr_24, 1, GRAPHICS_NORMAL);
  }
  else {
    dmd.drawString(2, 0, hr_24, 2, GRAPHICS_NORMAL);
  }
  //=====================================================
  
  //=====================================================Showing ":" in P10
  GetDateTime(); //-> Retrieve time and date data from DS1307
  if (_second %2 == 0) {
    dmd.drawString(14, 0, ":", 2, GRAPHICS_OR);
  }
  else {
    dmd.drawString(14, 0, ":", 2, GRAPHICS_NOR);
  }
  //=====================================================
  
  //=====================================================Showing minutes in P10
  str_mn=String(_minute);
  str_mn.toCharArray(mn,3);

  if (_minute<10) {
    dmd.drawString(19, 0, "0", 1, GRAPHICS_NORMAL);
    dmd.drawString(25, 0, mn, 1, GRAPHICS_NORMAL);
  }
  else {
    dmd.drawString(19, 0, mn, 2, GRAPHICS_NORMAL);
  }
  //=====================================================
}
//_____________________________________________________

//_____________________________________________________millis() for display & scrolling date
unsigned long currentMillis_for_date = millis();
if (currentMillis_for_date - previousMillis_for_date >= interval_for_date) {
  previousMillis_for_date = currentMillis_for_date; //-> save the last time 
  
  i--;
  dmd.drawString(i, 9, dt, strlen(dt), GRAPHICS_NORMAL);
  if (i<=~j) {
    dmd.clearScreen(true);
    delay(100);
    return;
  }
}

//_____________________________________________________

}

}
//------------------------------------------------------------------------

А нормально вставить код не судьба была? Читать ведь невозможно!

Не нашел в этой свалке, где Вы в коде пытались регулировать яркость.

И да, примите во внимание, что для полной яркости этой панели нужен блок питания на 3А

1 лайк

В самом вашем скетче есть упоминание про внешний источник питания 5 В для увеличения яркости…

По теории динамического отображения - для увелмчения яркости надо менять частоту или увеличивать скважность …
Со скважностью тут все сложно, а вот с частотой можно попробовать поэкспериментировать !

Поэкспериментировать с константой при инициализации TimerOne - 1000 микросекунд может и многовато, а может и наоборт это слишком часто…

И прежде чем печатать ответ - ВНИМАТЕЛЬНО прочитайте что написано в окне ввода текста после нажатия кнопки Ответить и исправьте вставку кода в своём первом сообщении !!!

1 лайк

@Komandir , в теории яркость от частоты не зависит. На практике она скорее падает при росте fps.

1 лайк

Глянул примеры этой библиотеки - там таймер настраивартся на 5000 микросекунд и scanDisplayBySPI() вызывается один раз …

почему то не могу редактировать, видимо время вышло, простите за тупость, попробую повторить, а блок питания у меня 5 ампер, я видел комментарии в скетче, да и от готового контроллера на максимальной яркости ток примерно 2 ампера в максимальном потреблении в статике, панель светится не вся, а примерно 35% светодиодов в режиме часов, дело не в бп явно.

//--------------------------------------------------------------------------------Arduino P10 Digital Clock Demo 2------------------------------------
/*
######################################################################################################################################################

Installation:
Arduino Uno DS1307
A5 ---------> SCL
A4 ---------> SDA
5V ---------> VCC
GND ---------> GND
######################################################################################################################################################

######################################################################################################################################################

DMD.h - Function and support library for the Freetronics DMD, a 512 LED matrix display panel arranged in a 32 x 16 layout.
Copyright (C) 2011 Marc Alexander (info freetronics com)
Installation:
Arduino Uno P10 Panel
13 ---------> S / CLK
11 ---------> R
9 ---------> nOE / OE
8 ---------> L / SCLK
7 ---------> B
6 ---------> A
GND ---------> GND
The P10 panel can still turn on without 5V Power Input if it only uses one panel, but to increase brightness it must be added with 5V Power Input.
5V Power Input must also be used if using more than one P10 Panel.
######################################################################################################################################################
*/

//--------------------------------------------------------------------------------------Wire and RTC Library
#include <Wire.h>
#include “RTClib.h”
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------The SPI, DMD, TimerOne and Font libraries are used.
#include <SPI.h>
#include <DMD.h>
//#include <DMD2.h>
#include <TimerOne.h>
#include “SystemFont5x7C.h” //SystemFont5x7.h или SystemFont5x7C.h
#include “Font_6x14.h” //-> This font only contains numbers from 0-9
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------Configuration P10
#define DISPLAYS_ACROSS 1 //-> Number of P10 panels used, side to side.
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
//--------------------------------------------------------------------------------------

RTC_DS1307 rtc; //-> RTC Declaration

//--------------------------------------------------------------------------------------Variables for time and date
int _day, _month, _year, _hour24, _hour12, _minute, _second, _dtw;
int hr24;
String st;
char nameoftheday[7][12] = {“BOCKPECEHbE”, “яOHEф”, “BTOPHuK”, “CPEфA”, “ЗETBEPу”, “яНTHшЖA”, “CГППюTA”};
char month_name[12][12] = {“01”,“02”, “03”, “04”, “05”, “06”, “07”, “08”, “09”, “10”, “11”, “12”};
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------Variable for Millis
const long interval = 1000; //-> Retrieve time and date data every 1 second
unsigned long previousMillis = 0;

const long interval_for_date = 75; //-> Скорость прокрутки даты бегущей строки (75 стандарт)
unsigned long previousMillis_for_date = 0;
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------Variable to display hours and minutes
char hr_24 [3];
String str_hr_24;
char mn [3];
String str_mn;
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------ScanDMD()
void ScanDMD() {
dmd.scanDisplayBySPI();
}

//--------------------------------------------------------------------------------------setup
//int pwm = 9; // This is the pin that we will use //
void setup() {
Serial.begin(115200);
// dmd.setBrightness(255);
// pinMode(pwm, OUTPUT); // declare the pin to be an output //
// analogWrite(pwm, 150); // medium brightness (50%)

Serial.println(“Arduino RTC DS1307”);
delay(1000);

if (! rtc.begin()) {
Serial.println(“Couldn’t find RTC”);
while (1);
}

if (! rtc.isrunning()) {
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled (Set the time and date based on your computer time and date)
// rtc.adjust(DateTime(F(DATE), F(TIME))); //-> Set the time and date based on your computer time and date. If that doesn’t work, use this line of code outside of “if (! rtc.isrunning())”
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
// following line sets the RTC to the date & time this sketch was compiled (Set the time and date based on your computer time and date)
//rtc.adjust(DateTime(F(DATE), F(TIME))); //-> Set the time and date based on your computer time and date. Use this line of code if it doesn’t work in “if (! rtc.isrunning())”
//rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
// If the time and date are successfully set, then deactivate the code line (make the code a comment), then re-upload the code.
// if not done then the time and date will return to the beginning when it was set when arduino is reset or restarted.

Timer1.initialize(1000);
Timer1.attachInterrupt(ScanDMD);
dmd.clearScreen(true);
}
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------loop
void loop() {

//_____________________________________________________millis() to display time
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; //-> save the last time

GetDateTime(); //-> Retrieve time and date data from DS1307

dmd.selectFont(Font_6x14);

//=====================================================Showing the clock in P10
str_hr_24=String(_hour24);
str_hr_24.toCharArray(hr_24,3);

if (_hour24<10) {
  dmd.drawString(0, 0, "0", 1, GRAPHICS_NORMAL);
  dmd.drawString(7, 0, hr_24, 1, GRAPHICS_NORMAL);
}
else {
  dmd.drawString(0, 0, hr_24, 2, GRAPHICS_NORMAL);
}
//=====================================================

//=====================================================Showing ":" in P10
if (_second %2 == 0) {
  dmd.drawFilledBox(15,3,16,4, GRAPHICS_OR);
  dmd.drawFilledBox(15,11,16,12, GRAPHICS_OR);
}
else {
  dmd.drawFilledBox(15,3,16,4, GRAPHICS_NOR);
  dmd.drawFilledBox(15,11,16,12, GRAPHICS_NOR);
}
//=====================================================

//=====================================================Showing minutes in P10
str_mn=String(_minute);
str_mn.toCharArray(mn,3);

if (_minute<10) {
  dmd.drawString(19, 0, "0", 1, GRAPHICS_NORMAL);
  dmd.drawString(26, 0, mn, 1, GRAPHICS_NORMAL);
}
else {
  dmd.drawString(19, 0, mn, 2, GRAPHICS_NORMAL);
}
//=====================================================

//=====================================================Call the scrolling_date() subroutine to display the date.
if (_second==11) { //-> Display the date when seconds equal to 11
  scrolling_date();
}
//=====================================================
}
//_____________________________________________________

}
//--------------------------------------------------------------------------------------

//------------------------------------------------------------------------Subroutine to retrieve or update the time and date from DS1307
void GetDateTime() {
DateTime now = rtc.now();
_day=now.day();
_month=now.month();
_year=now.year();
_hour24=now.hour();
_minute=now.minute();
_second=now.second();
_dtw=now.dayOfTheWeek();

hr24=_hour24;
if (hr24>12) {
_hour12=hr24-12;
}
else if (hr24==0) {
_hour12=12;
}
else {
_hour12=hr24;
}

if (hr24<12) {
st=“AM”;
}
else {
st=“PM”;
}
}
//------------------------------------------------------------------------

//------------------------------------------------------------------------Subroutine to display days, months and years
void scrolling_date() {

dmd.clearScreen(true);
delay(100);

//=====================================================Holds date data to display
String Date = String(nameoftheday[_dtw]) + ", " + String(_day) + “/” + String(month_name[_month-1]) + “/” + String(_year);
char dt[50];
Date.toCharArray(dt,50);
int i=32+10;
int j=strlen(dt)+(strlen(dt)*5);
//=====================================================

dmd.selectFont(SystemFont5x7C); //SystemFont5x7.h

while(1) {
//_____________________________________________________millis() to display time
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; //-> save the last time

//=====================================================Showing the clock in P10
  str_hr_24=String(_hour24);
  str_hr_24.toCharArray(hr_24,3);

  if (_hour24<10) {
    dmd.drawString(2, 0, "0", 1, GRAPHICS_NORMAL);
    dmd.drawString(8, 0, hr_24, 1, GRAPHICS_NORMAL);
  }
  else {
    dmd.drawString(2, 0, hr_24, 2, GRAPHICS_NORMAL);
  }
  //=====================================================
  
  //=====================================================Showing ":" in P10
  GetDateTime(); //-> Retrieve time and date data from DS1307
  if (_second %2 == 0) {
    dmd.drawString(14, 0, ":", 2, GRAPHICS_OR);
  }
  else {
    dmd.drawString(14, 0, ":", 2, GRAPHICS_NOR);
  }
  //=====================================================
  
  //=====================================================Showing minutes in P10
  str_mn=String(_minute);
  str_mn.toCharArray(mn,3);

  if (_minute<10) {
    dmd.drawString(19, 0, "0", 1, GRAPHICS_NORMAL);
    dmd.drawString(25, 0, mn, 1, GRAPHICS_NORMAL);
  }
  else {
    dmd.drawString(19, 0, mn, 2, GRAPHICS_NORMAL);
  }
  //=====================================================
}
//_____________________________________________________

//_____________________________________________________millis() for display & scrolling date
unsigned long currentMillis_for_date = millis();
if (currentMillis_for_date - previousMillis_for_date >= interval_for_date) {
  previousMillis_for_date = currentMillis_for_date; //-> save the last time 
  
  i--;
  dmd.drawString(i, 9, dt, strlen(dt), GRAPHICS_NORMAL);
  if (i<=~j) {
    dmd.clearScreen(true);
    delay(100);
    return;
  }
}

//_____________________________________________________
}

}
//------------------------------------------------------------------------

А примеры от этой библиотеки запускали ???

я сразу рабочий скетч запустил, библиотеку не смотрел.

Так где в скетче вы настраиваете яркость? И не вижу.
Она у вас по дефолту стоит

Я не нашел в этой библиотеке методов для яркости…
ТС попробуйте в 106 строке Timer1.initialize(5000) не успевают ваши светодиоды разгореться за 1 милисекунду.

1 лайк

значит это максимум

не нужен вам ШИМ, с ним будет только хуже.

Купите себе еще один контроллер, вы на гайвере хвастали, что он всего 5 баксов стоит. Сами вы лучше точно не сделаете, полгода уже пытаетесь, а толку ноль. Неужели полгода бессмысленной возни не стоят 500 рублей?

1 лайк

Зачем столько агрессии? Ничего я больше покупать не буду, у меня все есть, я не пытаюсь полгода что-то делать каждый день, зашел на форум третий раз, это не коммерческий проект и не мой заработок, чтобы сидеть с ним полгода или за деньги. Я загрузил с десяток готовых скетчей с часами, выбрал понравившийся и оставил, а там была другая задача посложнее (для меня), - адресная табличка с текстом, термометром и часами на дом, а тут просто обычные часы, я же не заставляю Вас мне отвечать и пишу в раздел для новичков ни на что не претендуя, помогут, - большое спасибо, не помогут, - ну не беда, оставлю как есть до лучших времен!

80 строка, я ее закомментировал, если раскоментить, то яркость включается хорошо только на первую секунду и светится часть цифр через строку, потом цифры загораются полностью но чуть слабее

Тогда дайте ссылку, где вы скачивали библиотеку. В той либе DMD, что я вижу на гитхабе - нет метода setBrightness()

setBrightness есть в DMD2 от той же конторы …

1 лайк

Сорри, просто для меня это личное :slight_smile:
Эти матрицы - мое хобби, я занимаюсь ими шестой год. Я обрадовался вашей теме на Гайвере и хотел помочь, но вы не восприимчивы к помощи.
В таком случае, без обид, лучше купить готовое и не тратить свое и чужое время на форумах.

ТС надо сначала погонять примеры использования библиотек ! А потом в ту что устраивает по яркости добавить часы …
DMD2 регулирует яркость через PWM, а в DMD надо подбирать константу для инициализации TimerOne.

Ярче, чем на DMD.h - все равно не будет.
В DMD.h нет регулировки яркости, она все время стоит на 100%.
В DMD2.h добавили яркость, но ее, естественно, можно только уменьшать.

Она подбирается по отсутствию мерцания панели и, в принципе, чем больше тем лучше. 1000 нормальное значение для Нано. Можно немного меньше, можно больше - где-то в диапазоне от 500 до 5000.

Но в целом, к проблемам ТС эта цифра отношения не имеет и ее можно не трогать.