DFRobot HT1632 Library HELP

Hello all!

I am making a project with the DFRobot HT1632 display. I try to compile the demo code though, and I get a list of errors that I have no idea how to fix. The whole list of errors seem to be very similar; something to do with a wrong "min" functions in the library... maybe?

Does anyone have any ideas on how to fix the errors and get this code compiling?

Thanks in advance!

Code:

#include "DFRobot_HT1632C.h"

#define DATA 10 //D6
#define CS 9    //D5
#define WR 13   //D7

DFRobot_HT1632C ht1632c = DFRobot_HT1632C(DATA, WR,CS);

char str[] = "DFROBOT 2017";

void setup() {
  Serial.begin(115200);
  // put your setup code here, to run once:
  ht1632c.begin();
  ht1632c.isLedOn(true);
  ht1632c.clearScreen();
  delay(500);
}

void loop() {
  // put your main code here, to run repeatedly:
  ht1632c.print(str,50);
  //delay(100);
}

Error:

/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp: In member function 'void DFRobot_HT1632C::drawImage(const byte*, uint8_t, uint8_t, int8_t, int8_t, int)':
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:464:57: error: no matching function for call to 'min(uint8_t&, int)'
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
In file included from /Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/algorithm:62,
                 from /Users/user/Library/Arduino15/packages/DFRobot/hardware/esp32/0.2.1/cores/esp32/Arduino.h:145,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.h:17,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:13:
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:464:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned char'
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
In file included from /Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/algorithm:62,
                 from /Users/user/Library/Arduino15/packages/DFRobot/hardware/esp32/0.2.1/cores/esp32/Arduino.h:145,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.h:17,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:13:
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)'
     min(initializer_list<_Tp> __l)
     ^~~
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:464:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned char'
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
In file included from /Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/algorithm:61,
                 from /Users/user/Library/Arduino15/packages/DFRobot/hardware/esp32/0.2.1/cores/esp32/Arduino.h:145,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.h:17,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:13:
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algobase.h:243:5: note: candidate: 'template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:464:57: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned char' and 'int')
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
In file included from /Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/algorithm:61,
                 from /Users/user/Library/Arduino15/packages/DFRobot/hardware/esp32/0.2.1/cores/esp32/Arduino.h:145,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.h:17,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:13:
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algobase.h:195:5: note: candidate: 'template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)'
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:464:57: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned char' and 'int')
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp: In member function 'void DFRobot_HT1632C::drawImageStr(const byte*, uint8_t, uint8_t, int8_t, int8_t, int)':
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:506:57: error: no matching function for call to 'min(uint8_t&, int)'
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
In file included from /Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/algorithm:62,
                 from /Users/user/Library/Arduino15/packages/DFRobot/hardware/esp32/0.2.1/cores/esp32/Arduino.h:145,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.h:17,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:13:
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:506:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned char'
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
In file included from /Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/algorithm:62,
                 from /Users/user/Library/Arduino15/packages/DFRobot/hardware/esp32/0.2.1/cores/esp32/Arduino.h:145,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.h:17,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:13:
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)'
     min(initializer_list<_Tp> __l)
     ^~~
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:506:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned char'
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
In file included from /Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/algorithm:61,
                 from /Users/user/Library/Arduino15/packages/DFRobot/hardware/esp32/0.2.1/cores/esp32/Arduino.h:145,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.h:17,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:13:
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algobase.h:243:5: note: candidate: 'template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:506:57: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned char' and 'int')
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
In file included from /Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/algorithm:61,
                 from /Users/user/Library/Arduino15/packages/DFRobot/hardware/esp32/0.2.1/cores/esp32/Arduino.h:145,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.h:17,
                 from /Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:13:
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algobase.h:195:5: note: candidate: 'template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)'
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/Users/user/Library/Arduino15/packages/DFRobot/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2020r3/xtensa-esp32-elf/include/c++/8.4.0/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
/Users/user/Desktop/Arduino/libraries/DFRobot_HT1632C/DFRobot_HT1632C.cpp:506:57: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned char' and 'int')
    copyInNextStep = min(copyInNextStep, (height - src_y));
                                                         ^
exit status 1
Error compiling for board FireBeetle ESP32-E.

It is obvious what is intended. I would replace the min() function call with an if statement.

Hello @jremington

Sorry, could you please show me an example?

It's because Arduino unwisely decided to redefine the min() function that already exists in C, with a macro that doesn't always work.

1 Like

You have been posting on this forum for some time now, and have yet to learn basic C/C++ programming. It is time to correct that failure.

You can replace

copyInNextStep = min(copyInNextStep, (height - src_y));

with

if (height - src_y < copyInNextStep) copyInNextStep = height - src_y;

I know; I am only 17yo and have never "learned" C/C++ coding. I get my experience from making projects. I know what the min functions does and the if function, but I am really flustered right now, so sorry.

Thanks for the example.

Expect that to continue for a long time, if you bumble along as you presently do.

No, I am flustered because this is for a competition project that ends in 9 days. I have another competition project that ends in ~20 days, and a third competition project that ends in ~1 month, not to mention multiple projects at home.

You don't have the skills required to program robots for a competition.

Why would you say that?

I'm not making a single robot.

I just finished fixing the library. It compiles now, but nothing happens on the display!

If that was a request for help, you need to post the updated sketch. We can't see it.

Sorry, the code is exactly identical to my first post.

All I did was exchange this:
copyInNextStep = min(copyInNextStep, (height - src_y));
with this:
if (height - src_y < copyInNextStep) copyInNextStep = height - src_y; in two different places in the "DFRobot_HT1632C.cpp" file.

I made sure to change the CS pin select switch on the bottom of the display, to "D5", to match the code.

Edit:
I also tried this code, but to no avail:

#include "DFRobot_HT1632C.h"

#define DATA D6
#define CS D5
#define WR D7
//#define RD 7

DFRobot_HT1632C ht1632c = DFRobot_HT1632C(DATA, WR,CS);

char str[] = "Hello";

void setup() {
  // put your setup code here, to run once:
  ht1632c.begin();
  ht1632c.isLedOn(true);
  ht1632c.clearScreen();
  ht1632c.setCursor(0,0);
  ht1632c.print(str);
}

void loop() {
  // put your main code here, to run repeatedly:

}

Are there no example sketches to test the display?

There is this one which I also tried but didn't work:

drawText.ino

#include "DFRobot_HT1632C.h"

#if defined( ESP_PLATFORM ) || defined( ARDUINO_ARCH_FIREBEETLE8266 )  //FireBeetle-ESP32 FireBeetle-ESP8266
#define DATA D6
#define CS D5
#define WR D7
//#define RD D8
#else
#define DATA 6
#define CS 5
#define WR 7
//#define RD 8
#endif

DFRobot_HT1632C ht1632c = DFRobot_HT1632C(DATA, WR,CS);

char text[] = "123";

void setup() {
  // put your setup code here, to run once:
  ht1632c.begin();
  ht1632c.isLedOn(true);
  ht1632c.clearScreen();
}

void loop() {
  // put your main code here, to run repeatedly:
  ht1632c.drawText(text, 0, 0, FONT_8X4, FONT_8X4_END, FONT_8X4_HEIGHT);
  ht1632c.writeScreen();
  delay(1000);
}

Where did you get it? If it's a library example, your hardware connections are probably bad.

That's bad, don't use third party software to test. Surely the library comes with its own example?

That's what im thinking, but the display is a shield; i.e. prewired.

Any other hardware connected?