B4R Question InLine C and Array of char

newbie

Member
Licensed User
Longtime User
after my first (stupid) problems are solved
i try to implement some functions of the UTFT-library.
The most works but i have problems to find out the right var to send the text.
UTFT wait for a String or a array of char to print, i have try to define the Text-Var as String or Byte-array
but get always compiler errors:

sketch\b4r_utft.cpp: In function 'void TftPrint(B4R::Object*)':
b4r_utft.cpp:44: error: no matching function for call to 'UTFT:: print(B4R::B4RString*&, Int&, Int&, int)'
myDisplay.print(b4r_utft::_text,b4r_utft::_zeile,b4r_utft::_spalte,0);
^
sketch\b4r_utft.cpp:44:71: note: candidates are:
In file included from sketch\b4r_utft.cpp:14:0:
C:\Arduino 1.6.12\libraries\UTFT/UTFT.h:219:8: note: void UTFT:: print(char*, int, int, int)
void print(char *st, int x, int y, int deg=0);
^

My Code is following:
B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.
   Private IsDark As Boolean
   Private Text As String
   'Private Text() As Byte
   Private Zeile As Int
   Private Spalte As Int
   Private Color As Int
End Sub


Sub InitDisplay
   RunNative("TftInit", Null)
   IsDark = False
End Sub

Sub LowDisplay
   RunNative("TftDark", Null)
   IsDark = True
End Sub

Sub ToDisplay(xZeile As Int, xSpalte As Int, xText As String)
   If IsDark Then
     RunNative("TftSetBackColorDunkel", Null)
   Else
     RunNative("TftSetBackColorHell", Null)
     Text.GetBytes(xText)
     Spalte = 16 * (xSpalte-1)
     Zeile = 16 * (xZeile-1)
     RunNative("TftPrint", Null)
   End If
End Sub

#If C
#include <UTFT.h>

extern uint8_t BigFont[];
UTFT myDisplay(TFT01_22SP,4,3,7,6,5);

void TftInit(B4R::Object* o) {
   myDisplay.InitLCD();
     myDisplay.setFont(BigFont);
     myDisplay.fillScr(255,255,255);
     myDisplay.setColor(0,0,0);
     myDisplay.setBackColor(255,255,255);
}

void TftDark(B4R::Object* o){
  myDisplay.InitLCD();
  myDisplay.setFont(BigFont);
  myDisplay.fillScr(50,50,50);
  myDisplay.setColor(0,0,0);
  myDisplay.setBackColor(50,50,50);  
}

void TftSetBackColorHell(B4R::Object* o) {
   myDisplay.setBackColor(255,255,255);
}

void TftSetBackColorDunkel(B4R::Object* o) {
   myDisplay.setBackColor(50,50,50);
}

void TftPrint(B4R::Object* o) {
   myDisplay.print(b4r_utft::_text,b4r_utft::_zeile,b4r_utft::_spalte,0);
}

#End If


Thanks for any suggestions
 

newbie

Member
Licensed User
Longtime User
Thanks, that works.
But there is still a little other Problem:

To refer the text in Inline i have define a private var Text as string
My Sub consigns the Text for the display also as string (xText as String)
How can i assign the Sub Var to my private var Text .
I have try Text.GetBytes(xText) but this Display nothing
 
Upvote 0
Top