Ukazuje to chybu při nahrávání, když použiji stejný název, tak u char bylo potřeba dát * , jinak to nešlo nahrát.
Kód: Vybrat vše
/*
* Interfacing Arduino with ST7789 TFT display (240x240 pixel).
* Graphics test example.
* This is a free software with NO WARRANTY.
* https://simple-circuit.com/
*/
/**************************************************************************
This is a library for several Adafruit displays based on ST77* drivers.
Works with the Adafruit 1.8" TFT Breakout w/SD card
----> http://www.adafruit.com/products/358
The 1.8" TFT shield
----> https://www.adafruit.com/product/802
The 1.44" TFT breakout
----> https://www.adafruit.com/product/2088
as well as Adafruit raw 1.8" TFT display
----> http://www.adafruit.com/products/618
Check out the links above for our tutorials and wiring diagrams.
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional).
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
**************************************************************************/
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h> // Arduino SPI library
// ST7789 TFT module connections
#define TFT_CS 10 // define chip select pin
#define TFT_DC 9 // define data/command pin
#define TFT_RST 8 // define reset pin, or set to -1 and connect to Arduino RESET pin
// Initialize Adafruit ST7789 TFT library
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;
float ppp = 6.1415926;
void setup(void) {
Serial.begin(9600);
Serial.print(F("Hello! ST77xx TFT Test"));
// if the display has CS pin try with SPI_MODE0
tft.init(240, 240, SPI_MODE2); // Init ST7789 display 240x240 pixel
// if the screen is flipped, remove this command
tft.setRotation(1);
Serial.println(F("Initialized"));
tft.fillScreen(ST77XX_BLACK);
}
void loop() {
//// large block of text
// tft.fillScreen(ST77XX_BLACK);
// tft.setTextSize(2);
// tft.setTextColor(ST77XX_WHITE);
// //tft.setTextColor(0xFEA6);
// tft.setCursor(0, 0);
// tft.print("Down ");
// //tft.setTextColor(ST77XX_WHITE);
// tft.setTextColor(0xFEA6);
// tft.setCursor(0, 20);
// tft.print("Down ");
// tft.setTextColor(ST77XX_GREEN);
// tft.setCursor(0, 40);
// tft.print("Down ");
// tft.setTextColor(ST77XX_ORANGE);
// tft.setCursor(0, 60);
// tft.print("Down ");
// tft.setTextColor(ST77XX_BLUE);
// tft.setCursor(0, 80);
// tft.print("Down ");
// tft.setTextColor(ST77XX_RED);
// tft.setCursor(0, 100);
// tft.print("Down ");
// tft.setTextColor(ST77XX_CYAN);
// tft.setCursor(0, 120);
// tft.print("Down ");
// tft.setTextColor(ST77XX_MAGENTA);
// tft.setCursor(0, 140);
// tft.print("Down ");
// tft.setTextColor(ST77XX_MAGENTA);
// tft.setCursor(0, 160);
// tft.print("Down ");
// tft.setTextColor(ST77XX_MAGENTA);
// tft.setCursor(0, 180);
// tft.print("Down ");
// tft.setTextColor(ST77XX_WHITE);
// tft.setCursor(0, 200);
// tft.print("Down ");
// tft.setTextSize(4);
// tft.setTextColor(0xFDA0);
// tft.setCursor(160, 150);
tft.fillScreen(ST77XX_BLACK);
//displej(2, ST77XX_WHITE, 0, 0, "ahoj");
//displej(3, ST77XX_WHITE, 0, 30, "huhuhu");
displej(3, ST77XX_BLUE, 0, 60, "ahoj:");
displej(2, 0xFDA0, 80, 60, p);
delay(5000);
}
void displej(int velikost, char BarvaTextu, int pozice, int radek, char *textik){
tft.setTextSize(velikost);
tft.setTextColor(BarvaTextu);
tft.setCursor(pozice, radek);
tft.print(textik);
}
void displej(int velikost, char BarvaTextu, int pozice, int radek, int textik){
tft.setTextSize(velikost);
tft.setTextColor(BarvaTextu);
tft.setCursor(pozice, radek);
tft.print(textik);
}
Kód: Vybrat vše
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino: In function 'void loop()':
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:106:39: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
displej(3, ST77XX_BLUE, 0, 60, "ahoj:");
^
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:107:29: warning: overflow in implicit constant conversion [-Woverflow]
displej(2, 0xFDA0, 80, 60, p);
^
Projekt zabírá 10842 bytů (33%) úložného místa pro program. Maximum je 32256 bytů.
Globální proměnné zabírají 314 bytů (15%) dynamické paměti, 1734 bytů zůstává pro lokální proměnné. Maximum je 2048 bytů.
A bez použití * to dá chybu a nenahraje.
Kód: Vybrat vše
Arduino: 1.8.13 (Linux), Vývojová deska: "Arduino Uno"
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino: In function 'void loop()':
sketch_sep18a:106:39: error: no matching function for call to 'displej(int, int, int, int, const char [6])'
displej(3, ST77XX_BLUE, 0, 60, "ahoj:");
^
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:111:6: note: candidate: void displej(int, char, int, int, char) <near match>
void displej(int velikost, char BarvaTextu, int pozice, int radek, char textik){
^~~~~~~
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:111:6: note: conversion of argument 5 would be ill-formed:
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:106:39: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
displej(3, ST77XX_BLUE, 0, 60, "ahoj:");
^
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:117:6: note: candidate: void displej(int, char, int, int, int) <near match>
void displej(int velikost, char BarvaTextu, int pozice, int radek, int textik){
^~~~~~~
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:117:6: note: conversion of argument 5 would be ill-formed:
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:106:39: warning: invalid conversion from 'const char*' to 'int' [-fpermissive]
displej(3, ST77XX_BLUE, 0, 60, "ahoj:");
^
sketch_sep18a:107:29: error: call of overloaded 'displej(int, unsigned int, int, int, float&)' is ambiguous
displej(2, 0xFDA0, 80, 60, p);
^
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:111:6: note: candidate: void displej(int, char, int, int, char)
void displej(int velikost, char BarvaTextu, int pozice, int radek, char textik){
^~~~~~~
/home/pi/Documents/Arduino/kody k testu/test/sketch_sep18a/sketch_sep18a.ino:117:6: note: candidate: void displej(int, char, int, int, int)
void displej(int velikost, char BarvaTextu, int pozice, int radek, int textik){
^~~~~~~
exit status 1
no matching function for call to 'displej(int, int, int, int, const char [6])'