• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Problem z ILI9481
#1
Witam.
Próbuję swych sił z arduino mega2560 i wyświetlaczem ILI9481.
Co ciekawe wyświetlenie tekstu nie stanowi problemu.
Natomiast przy próbie wyrzucenia jakiejś zmiennej mam krzaczek albo kwadracik.
Program ma na celu zmierzenie na wejściu A5 napięcia i wyświetleniu na wyświetlaczu.
Pod spodem KOD:
Kod:
#include <Wire.h> //I2C Arduino Library
#include <UTFT.h> // UTFT Library from Henning Karlsen (http://www.rinkydinkelectronics.com/library.php)
#include <UTFT_Geometry.h> //UTFT Geometry Library from Henning Karlsen (http://www.rinkydinkelectronics.com/library.php)
#include <Keypad.h>
#include <EEPROM.h>
#include "math.h"
const int X  = 320;
const int Y  = 160;
const int dm  = 130;
const int x_Offset = 30;
const int y_Offset = 128;
const int z_Offset = 0;
const byte rows = 4; // Four rows
const byte cols = 3; // Three columns
const int maxDegreeDigits = 3; //maximum allowed input length
const int fixedInflight = 5;
const long maxInflight = 25;
const long maxDeclinationDegree = 99;
const long maxDeclinationMinute = 59;
extern uint8_t BigFont[];
extern uint8_t SmallFont[];
extern uint8_t SevenSegmentFull[];
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
#define ORANGE  0xFF00
#define TonePin      (4)    // Pin for beeper
#define ToneSwitch   (2)    // one end of 3 way toggle switch
#define PEPswitch    (3)    // the other end of 3 way toggle switch
#define ModeSwitch   (5)    // push button switch (no 3 way toggle switch)
#define BANDSwitch   (6)    // push button switch band change
#define LCDbacklight (13)   // output to power the LCD backlight
#define VoltSupplyMini (20) // minimum battery voltage expressed in 100mV (if lower, alarm is generated)
//                          // for Âľ7805, minimum 7v required
// voltage divider at A5  - select proper values so that voltage never exceeds 5v on A5 !
// With R1 = 1k2 and R2 = 4k7, max input voltage = 25v

#define R1           (10)   // from GND to A5, express in 100R  (12 = 1200 Ohm)
#define R2           (47)   // from + power supply to A5, express in 100R  (47 = 4700 Ohm)
#define PowCalHF     (100)    // HF band
#define PowCal6m     (21)     // 6m band
#define PowCal4m     (30)     // 4m band  --> pmax @ 5000mV = 833 W (as example)
#define PowCal2m     (117)    // 2m band
#define PowCal70     (57)     // 70cm band
#define PowCal23     (3165)   // 23cm band
#define PowCal13     (64800)  // 13cm band

char* myStrings[] = {"  HF ", "  6m ", "  4m ", "  2m ", " 70cm", " 23cm", " 13cm"};
/////////////////////// 3 way-mode switch or pushbutton ? ///////////////////////////////////

int PushButton = (1);           // 1 = Pushbutton  /  0 = toggle switch
// there is an automatic detection in the display subroutine

////////////////////////////////////////////////////////////////////////////////////////////
// modes
byte PEP = (1);                   // 0 if PEP measured
byte Tone = (1);                  // 0 if tone SWR tune (bip)

byte MODE = (0);                  // Mode 0 = instant power / Mode 1 = PEP / Mode 2 = Bip
byte BAND = (0);                  // BAND 0 = HF / 1 = 6m  / 2 = 4m / 3 = 2m  / 4 = 70cm  / 5 = 23cm  / 6 = 13cm

unsigned long DisplayTime = 0;    // timer display refresh
unsigned long PeakTime = 0;       // timer peak (PEP) detect
unsigned long BacklightTime = 0;  // backlight LCD hold time
unsigned long BandTime = 0;       // band display hold time

float VoltFWD = 0;
float VoltFWDmax = 0;
float VoltPEP = 0;
float VoltREF = 0;

unsigned int Diode = 130;         // diode forward voltage, expressed in mV

unsigned int PowCal = 103 ;       // calibration factor for power: PowCal=(VoltFWD²/Power)*1000
unsigned long PWR = 0;            // power (expressed in 100 mW)
unsigned int PowDis = 0;          // power for display
float SWR = 0;                    // SWR
float Vratio = 0;                 // Voltage ratio VoltREF/VoltFWD

int SWRDis = 0;                  // power calculation for showing in display

int VoltFWDmini = 0;

unsigned long PWRmax = 0;         // the maximum power range, band dependant

int beeponce = (0);              // emit only 1 beep for modechange
int beepband = (0);              // emit only 1 beep for bandchange

int SWRtonePitch = (800);        // low lone = low SWR
int SWRtoneLenght = (100);       // long tone = low SWR

int debugled = (0);              // LED at pin13 = debug
int decay = (0);                 // PEP decay rate

unsigned int SupplyVoltage = (0); // Power supply voltage

byte RunOnce = (1);               // detect wether in SETUP or LOOP mode
byte DisplayCycle = (0);          // counts the cycles in display mode (for low volt alert)


UTFT utftDisplay(ILI9481, 38, 39, 40, 41);
UTFT_Geometry geo(&utftDisplay);

void setup() {
 Serial.begin(9600);
 InitializeDisplay();

 //setup pins
 pinMode(PEPswitch, INPUT);      // if grounded --> 'PEP' mode
 pinMode(ToneSwitch, INPUT);     // if grounded  --> 'Bip' mode
 pinMode(ModeSwitch, INPUT);     // if grounded  --> cycle through modes
 pinMode(BANDSwitch, INPUT);     // if grounded  --> cycle through bands

 // READ mode from EEPROM & set parameters
MODE = EEPROM.read(1);
      if (MODE == 0) {         // normal instant power & SWR
             Tone = 1;
             PEP = 1; }
      if (MODE == 1) {        // Tone tune SWR
             Tone = 1;
             PEP = 0; }
      if (MODE == 2) {        // PEP power
             Tone = 0;
             PEP = 1; }
   
// READ band from EEPROM
 BAND = EEPROM.read(2);
       if (BAND == 0) {        
             BAND = 3;            // No HF for time being, default = 2m
             PowCal = PowCalHF;}
       if (BAND == 1) {        
             PowCal = PowCal6m;}    
       if (BAND == 2) {        
             PowCal = PowCal4m;}
       if (BAND == 3) {        
             PowCal = PowCal2m;}    
       if (BAND == 4) {        
             PowCal = PowCal70;}
       if (BAND == 5) {        
             PowCal = PowCal23;}    
       if (BAND == 6) {        
             PowCal = PowCal13;}

   

}

void loop()
{

}
void InitializeDisplay()
{
 utftDisplay.InitLCD();
 utftDisplay.InitLCD(LANDSCAPE);
 utftDisplay.clrScr();
 utftDisplay.setFont(BigFont);
 utftDisplay.setColor(255, 128, 0);
 utftDisplay.print("JAKIS TAM TEKST", CENTER, 12);
  //  utftDisplay.clrScr();


}

void measuresupplyvolt () {    // Power SupplyVoltage measure

 SupplyVoltage = analogRead(A5);        // Read power supply voltage
 SupplyVoltage = map(SupplyVoltage, 0, 1023, 0, (50 * (R2 + R1) / R1));
 if (SupplyVoltage <= 5) return;       // not running on batteries !
 if (SupplyVoltage >= 84) SupplyVoltage = SupplyVoltage + 6 ; // running on ext power, correct for diode voltage drop 0.6v

 // print power supply voltage if startup or low battery condition

 if ((RunOnce == 1)  or  (SupplyVoltage <= VoltSupplyMini))   {


   utftDisplay.print("Batt Volt=", LEFT, 53);
   utftDisplay.setColor(WHITE);
   utftDisplay.print(SupplyVoltage/10, LEFT, 53);
   //utftDisplay.print(".",LEFT,50,50);
    //utftDisplay.print(SupplyVoltage%10 , LEFT, 80);
    // utftDisplay.print("V",LEFT, 53, 120);
   if   (SupplyVoltage  <= VoltSupplyMini) {
     utftDisplay.print("LOW BATTERY", LEFT, 120);
   }
   delay (1500);
 }

}
 
Odpowiedź
#2
Nie mam takiego wyświetlacza, nigdy go nie używałem ale zawsze zaczynam od przeczytania dokumentacji i przykładów.
Do wyświetlenia wartości typu int powinieneś użyć funkcji 'printNumI' a nie 'print'.
Nawet gdyby nie było funkcji która wyświetla zmienna typu int to wystarczyłoby zamienić tę zmienną na string i wyświetlić przy użyciu 'print'.
Pomagam za darmo więc szanuj mój czas.
Wklejaj tekst a nie jego zdjęcie.
Nie pisz następnego postu jak nie odpowiedziałeś na poprzedni.
Jak mądrze zadawać pytania
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości