B4R Code Snippet 7 segment display (with dots)

Similar threads

B4R Tutorial Inline C / C++
B4R Tutorial HC 05 Classic Bluetooth
B4R Tutorial Additional Hardware Serial Ports
B4R Code Snippet GFX and Bitmaps
B4R Tutorial SevSeg with inline C

derez

Expert
Licensed User
Following Kevins post here https://www.b4x.com/android/forum/t...git-led-display-not-working.93929/post-594225 and finding myself with similar problem, I wrote some inline c code to control the display.
Sorry to say, I still can't get the dots to light :(
I used the display for a night clock:
1603653250529.png


Using the library mentioned by Kevin in the post above I have found that Arduino UNO, NANO, ESP32 (WEMOS or ESP32S) compile and show on the display, while ESP8266, nodemcu and LGT8F328P don't. Accordingly I could use either ESP32 (display and wifi) or NANO (display)+ Nodemcu (wifi).
The following code is used for the clock:
B4X:
Private Sub AppStart
    Serial1.Initialize(115200)
    Log("appstart")


    RunNative("begin", Null)
    Light = 20
    RunNative("setbacklight", Null)
    RunNative("setcolon", Null)

    RunNative("printtxt", Null)
    ...
End Sub

Sub print_at(num As UInt, place As UInt)
    Number = num
    Position = place
    RunNative("setcursor", Null)
    RunNative("print", Null)
End Sub

Sub showtime
    If hour = 0 Then
        print_at( minute + 1000, 0)
    
        Raw = 0x0
        Position = 0
        RunNative("printRaw", Null)

    else if hour < 10 Then
        print_at(hour * 100 + minute, 1)

        Raw = 0x0
        Position = 0
        RunNative("printRaw", Null)

    Else
        print_at(hour * 100 + minute, 0)

    End If
End Sub


#if c

// include the SevenSegmentTM1637 library
#include "SevenSegmentTM1637.h"
const byte PIN_CLK = 5;   // define CLK pin (any digital pin)
const byte PIN_DIO = 6;   // define DIO pin (any digital pin)
SevenSegmentTM1637    display(PIN_CLK,  PIN_DIO);

void begin (B4R::Object* o) {
   display.begin();
}

void print (B4R::Object* o) {
   //lower case variables
      display.print(b4r_main::_number);
}

void printtxt (B4R::Object* o) {
//    display.print(b4r_main::_txt) ;
      display.print("____");
}

void setcolon (B4R::Object* o) {
      display.setColonOn(1);
}

void clear (B4R::Object* o) {
   display.print("    ");
}

void setbacklight (B4R::Object* o) {
   display.setBacklight(b4r_main::_light);
}

void printRaw (B4R::Object* o) {
   display.printRaw(b4r_main::_raw, b4r_main::_position);
}

void setcursor (B4R::Object* o) {
   display.setCursor(0, b4r_main::_position);
}

#end if
I don't know how to pass a string to this function (the commented line) , if someone can teach me I'll appreciate ! Until then, only predefined strings can be displayed with this code.
B4X:
void printtxt (B4R::Object* o) {
//    display.print(b4r_main::_txt) ;
      display.print("____");
}
In the h file of the library there is a list of all RAW codes for the various characters.
 
Last edited:

tigrot

Well-Known Member
Licensed User
This is a complex example of labels handling, where the strings are stored in flash memory(program memory)
There are also examples of strings handling.
The result is put on a local variable called stringa. The module name is statica
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public stringa() As Byte
    Public parametri(1024) As Byte =Array As Byte(50, 0, 0, 0, 1, 1, 0, 180, 250, 0, 9, 0, 0, 0, 1, 0, 100, 100, 1, 50, 0, 10, 0, 0,  48,  32,  73,  78,  65,  84,  84,  73,  86,  79, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  32,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  32,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  32,  40,  78,  111,  116,  83,  101,  116,  51, 2, 97, 96, 3, 52, 0, 10, 0, 0,  52,  32,  40,  78,  111,  116,  83,  101,  65,  52, 2, 96, 95, 1, 50, 0, 10, 0, 0,  53,  32,  40,  110,  111,  116,  83,  101,  116,  41, 3, 94, 94, 1, 50, 0, 10, 0, 0,  54,  32,  40,  78,  111,  116,  83,  103,  49,  50, 0, 100, 100, 1, 50, 0, 10, 0, 0,  55,  32,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  56,  32,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  57,  32,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  48,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  49,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  50,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  51,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  52,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  53,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  54,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  55,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  56,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  49,  57,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  48,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  49,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  50,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  51,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  52,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  53,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  54,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  55,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  56,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  50,  57,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  48,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  49,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  50,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  51,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  52,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  53,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  54,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  55,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  56,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  51,  57,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  48,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  49,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  50,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  51,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  52,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  53,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  54,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  55,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  56,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  52,  57,  40,  78,  111,  116,  83,  101,  116,  41, 0, 100, 100, 1, 50, 0, 10, 0, 0,  53,  48,  40,  78,  111,  116,  83,  101,  116,  50,  49,  50,  51,  52,  53,  54,  55,  56,  57,  48,  48,  48,48,  48,  48,48,  48,  48,48,  48,  48,48,  48,  48,48,  48,  48,48,  48,  48,48,  48,  48,48,  48,  48)
        Dim ct As Int=0 'start parametro
  
End Sub
Public Sub leggiparame(dummy As Byte,param() As Byte) As Int
    Dim ritorno As Int=0
    Dim tofind As Int=0
    ct=1
    Dim cend As Int=1 'fine parametro
    ct=SizeOf(param)
    For ct=ct-1 To 1 Step -1
      Dim mult As Int =cend 
      tofind=tofind+((param(ct)-48)*mult)
      cend=cend*10 
    Next
    'tofind=tofind+1
    cend=0
    ct=0     
'    ''log("dacercare: ",tofind)
    Do While tofind>GetByte(ct)
        ct=ct+1
    Loop
    cend=ct
'    ''log("GetByte1:",GetByte(cend))
    Do While tofind=GetByte(cend)
        cend=cend+1
        ritorno=ritorno+1
    Loop
    Return ritorno
End Sub
Public Sub GetByte(Index As UInt) As Int
    Return RunNative("getdata", Index)
End Sub

public Sub GetString(index As UInt) As Int  'read table via relative index
      RunNative("getdata1", index)
End Sub
public Sub FindString(src() As Byte)  'Lookup table
      ''log("Findstring:",src)
      RunNative("findstring", src)
      Return
End Sub

#if C
#include <avr/pgmspace.h>
char strx[50];
const PROGMEM int data[] = { //change the data here
           0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 ,  8 ,
           9 ,  10 ,  11 ,  12 ,  13 ,  14 ,  15 ,
           16 ,  17 ,  18 ,  19 ,  20 ,  21 ,  22 ,
           23 ,  24 ,  24 ,  24 ,  24 ,  24 ,  24 ,
           24 ,  24 ,  24 ,  24 ,  25 ,  26 ,  27 ,
           28 ,  29 ,  30 ,  31 ,  32 ,  33 ,  34 ,
           34 ,  34 ,  34 ,  34 ,  34 ,  34 ,  34 ,
           34 ,  34 ,  35 ,  36 ,  37 ,  38 ,  39 ,
           40 ,  41 ,  42 ,  43 ,  44 ,  44 ,  44 ,
           44 ,  44 ,  44 ,  44 ,  44 ,  44 ,  44 ,
           45 ,  46 ,  47 ,  48 ,  49 ,  50 ,  51 ,
           52 ,  53 ,  54 ,  54 ,  54 ,  54 ,  54 ,
           54 ,  54 ,  54 ,  54 ,  54 ,  55 ,  56 ,
           57 ,  58 ,  59 ,  60 ,  61 ,  62 ,  63 ,
           64 ,  64 ,  64 ,  64 ,  64 ,  64 ,  64 ,
           64 ,  64 ,  64 ,  65 ,  66 ,  67 ,  68 ,
           69 ,  70 ,  71 ,  72 ,  73 ,  74 ,  74 ,
           74 ,  74 ,  74 ,  74 ,  74 ,  74 ,  74 ,
           74 ,  75 ,  76 ,  77 ,  78 ,  79 ,  80 ,
           81 ,  82 ,  83 ,  84 ,  84 ,  84 ,  84 ,
           84 ,  84 ,  84 ,  84 ,  84 ,  84 ,  85 ,
           86 ,  87 ,  88 ,  89 ,  90 ,  91 ,  92 ,
           93 ,  94 ,  94 ,  94 ,  94 ,  94 ,  94 ,
           94 ,  94 ,  94 ,  94 ,  95 ,  96 ,  97 ,
           98 ,  99 ,  100 ,  101 ,  102 ,  103 ,  104 ,
           104 ,  104 ,  104 ,  104 ,  104 ,  104 ,
           104 ,  104 ,  104 ,  105 ,  106 ,  107 ,
           108 ,  109 ,  110 ,  111 ,  112 ,  113 ,
           114 ,  114 ,  114 ,  114 ,  114 ,  114 ,
           114 ,  114 ,  114 ,  114 ,  115 ,  116 ,
           117 ,  118 ,  119 ,  120 ,  121 ,  122 ,
           123 ,  124 ,  124 ,  124 ,  124 ,  124 ,
           124 ,  124 ,  124 ,  124 ,  124 ,  125 ,
           126 ,  127 ,  128 ,  129 ,  130 ,  131 ,
           132 ,  133 ,  134 ,  134 ,  134 ,  134 ,
           134 ,  134 ,  134 ,  134 ,  134 ,  134 ,
           135 ,  136 ,  137 ,  138 ,  139 ,  140 ,
           141 ,  142 ,  143 ,  144 ,  144 ,  144 ,
           144 ,  144 ,  144 ,  144 ,  144 ,  144 ,
           144 ,  145 ,  146 ,  147 ,  148 ,  149 ,
           150 ,  151 ,  152 ,  153 ,  154 ,  154 ,
           154 ,  154 ,  154 ,  154 ,  154 ,  154 ,
           154 ,  154 ,  155 ,  156 ,  157 ,  158 ,
           159 ,  160 ,  161 ,  162 ,  163 ,  164 ,
           164 ,  164 ,  164 ,  164 ,  164 ,  164 ,
           164 ,  164 ,  164 ,  165 ,  166 ,  167 ,
           168 ,  169 ,  170 ,  171 ,  172 ,  173 ,
           174 ,  174 ,  174 ,  174 ,  174 ,  174 ,
           174 ,  174 ,  174 ,  174 ,  175 ,  176 ,
           177 ,  178 ,  179 ,  180 ,  181 ,  182 ,
           183 ,  184 ,  184 ,  184 ,  184 ,  184 ,
           184 ,  184 ,  184 ,  184 ,  184 ,  185 ,
           186 ,  187 ,  188 ,  189 ,  190 ,  191 ,
           192 ,  193 ,  194 ,  194 ,  194 ,  194 ,
           194 ,  194 ,  194 ,  194 ,  194 ,  194 ,
           195 ,  196 ,  197 ,  198 ,  199 ,  200 ,
           201 ,  202 ,  203 ,  204 ,  204 ,  204 ,
           204 ,  204 ,  204 ,  204 ,  204 ,  204 ,
           204 ,  205 ,  206 ,  207 ,  208 ,  209 ,
           210 ,  211 ,  212 ,  213 ,  214 ,  214 ,
           214 ,  214 ,  214 ,  214 ,  214 ,  214 ,
           214 ,  214 ,  215 ,  216 ,  217 ,  218 ,
           219 ,  220 ,  221 ,  222 ,  223 ,  224 ,
           224 ,  224 ,  224 ,  224 ,  224 ,  224 ,
           224 ,  224 ,  224 ,  225 ,  226 ,  227 ,
           228 ,  229 ,  230 ,  231 ,  232 ,  233 ,
           234 ,  234 ,  234 ,  234 ,  234 ,  234 ,
           234 ,  234 ,  234 ,  234 ,  235 ,  236 ,
           237 ,  238 ,  239 ,  240 ,  241 ,  242 ,
           243 ,  244 ,  244 ,  244 ,  244 ,  244 ,
           244 ,  244 ,  244 ,  244 ,  244 ,  245 ,
           246 ,  247 ,  248 ,  249 ,  250 ,  251 ,
           252 ,  253 ,  254 ,  254 ,  254 ,  254 ,
           254 ,  254 ,  254 ,  254 ,  254 ,  254 ,
           255 ,  256 ,  257 ,  258 ,  259 ,  260 ,
           261 ,  262 ,  263 ,  264 ,  264 ,  264 ,
           264 ,  264 ,  264 ,  264 ,  264 ,  264 ,
           264 ,  265 ,  266 ,  267 ,  268 ,  269 ,
           270 ,  271 ,  272 ,  273 ,  274 ,  274 ,
           274 ,  274 ,  274 ,  274 ,  274 ,  274 ,
           274 ,  274 ,  275 ,  276 ,  277 ,  278 ,
           279 ,  280 ,  281 ,  282 ,  283 ,  284 ,
           284 ,  284 ,  284 ,  284 ,  284 ,  284 ,
           284 ,  284 ,  284 ,  285 ,  286 ,  287 ,
           288 ,  289 ,  290 ,  291 ,  292 ,  293 ,
           294 ,  294 ,  294 ,  294 ,  294 ,  294 ,
           294 ,  294 ,  294 ,  294 ,  295 ,  296 ,
           297 ,  298 ,  299 ,  300 ,  301 ,  302 ,
           303 ,  304 ,  304 ,  304 ,  304 ,  304 ,
           304 ,  304 ,  304 ,  304 ,  304 ,  305 ,
           306 ,  307 ,  308 ,  309 ,  310 ,  311 ,
           312 ,  313 ,  314 ,  314 ,  314 ,  314 ,
           314 ,  314 ,  314 ,  314 ,  314 ,  314 ,
           315 ,  316 ,  317 ,  318 ,  319 ,  320 ,
           321 ,  322 ,  323 ,  324 ,  324 ,  324 ,
           324 ,  324 ,  324 ,  324 ,  324 ,  324 ,
           324 ,  325 ,  326 ,  327 ,  328 ,  329 ,
           330 ,  331 ,  332 ,  333 ,  334 ,  334 ,
           334 ,  334 ,  334 ,  334 ,  334 ,  334 ,
           334 ,  334 ,  335 ,  336 ,  337 ,  338 ,
           339 ,  340 ,  341 ,  342 ,  343 ,  344 ,
           344 ,  344 ,  344 ,  344 ,  344 ,  344 ,
           344 ,  344 ,  344 ,  345 ,  346 ,  347 ,
           348 ,  349 ,  350 ,  351 ,  352 ,  353 ,
           354 ,  354 ,  354 ,  354 ,  354 ,  354 ,
           354 ,  354 ,  354 ,  354 ,  355 ,  356 ,
           357 ,  358 ,  359 ,  360 ,  361 ,  362 ,
           363 ,  364 ,  364 ,  364 ,  364 ,  364 ,
           364 ,  364 ,  364 ,  364 ,  364 ,  365 ,
           366 ,  367 ,  368 ,  369 ,  370 ,  371 ,
           372 ,  373 ,  374 ,  374 ,  374 ,  374 ,
           374 ,  374 ,  374 ,  374 ,  374 ,  374 ,
           375 ,  376 ,  377 ,  378 ,  379 ,  380 ,
           381 ,  382 ,  383 ,  384 ,  384 ,  384 ,
           384 ,  384 ,  384 ,  384 ,  384 ,  384 ,
           384 ,  385 ,  386 ,  387 ,  388 ,  389 ,
           390 ,  391 ,  392 ,  393 ,  394 ,  394 ,
           394 ,  394 ,  394 ,  394 ,  394 ,  394 ,
           394 ,  394 ,  395 ,  396 ,  397 ,  398 ,
           399 ,  400 ,  401 ,  402 ,  403 ,  404 ,
           404 ,  404 ,  404 ,  404 ,  404 ,  404 ,
           404 ,  404 ,  404 ,  405 ,  406 ,  407 ,
           408 ,  409 ,  410 ,  411 ,  412 ,  413 ,
           414 ,  414 ,  414 ,  414 ,  414 ,  414 ,
           414 ,  414 ,  414 ,  414 ,  415 ,  416 ,
           417 ,  418 ,  419 ,  420 ,  421 ,  422 ,
           423 ,  424 ,  424 ,  424 ,  424 ,  424 ,
           424 ,  424 ,  424 ,  424 ,  424 ,  425 ,
           426 ,  427 ,  428 ,  429 ,  430 ,  431 ,
           432 ,  433 ,  434 ,  434 ,  434 ,  434 ,
           434 ,  434 ,  434 ,  434 ,  434 ,  434 ,
           435 ,  436 ,  437 ,  438 ,  439 ,  440 ,
           441 ,  442 ,  443 ,  444 ,  444 ,  444 ,
           444 ,  444 ,  444 ,  444 ,  444 ,  444 ,
           444 ,  445 ,  446 ,  447 ,  448 ,  449 ,
           450 ,  451 ,  452 ,  453 ,  454 ,  454 ,
           454 ,  454 ,  454 ,  454 ,  454 ,  454 ,
           454 ,  454 ,  455 ,  456 ,  457 ,  458 ,
           459 ,  460 ,  461 ,  462 ,  463 ,  464 ,
           464 ,  464 ,  464 ,  464 ,  464 ,  464 ,
           464 ,  464 ,  464 ,  465 ,  466 ,  467 ,
           468 ,  469 ,  470 ,  471 ,  472 ,  473 ,
           474 ,  474 ,  474 ,  474 ,  474 ,  474 ,
           474 ,  474 ,  474 ,  474 ,  475 ,  476 ,
           477 ,  478 ,  479 ,  480 ,  481 ,  482 ,
           483 ,  484 ,  484 ,  484 ,  484 ,  484 ,
           484 ,  484 ,  484 ,  484 ,  484 ,  485 ,
           486 ,  487 ,  488 ,  489 ,  490 ,  491 ,
           492 ,  493 ,  494 ,  494 ,  494 ,  494 ,
           494 ,  494 ,  494 ,  494 ,  494 ,  494 ,
           495 ,  496 ,  497 ,  498 ,  499 ,  500 ,
           501 ,  502 ,  503 ,  504 ,  504 ,  504 ,
           504 ,  504 ,  504 ,  504 ,  504 ,  504 ,
           504 ,  505 ,  506 ,  507 ,  508 ,  509 ,
           510 ,  511 ,  512 ,  513 ,  514 ,  514 ,
           514 ,  514 ,  514 ,  514 ,  514 ,  514 ,
           514 ,  514 ,  515 ,  516 ,  517 ,  518 ,
           519 ,  520 ,  521 ,  522 ,  523 ,  524 ,
           524 ,  524 ,  524 ,  524 ,  524 ,  524 ,
           524 ,  524 ,  524 ,  525 ,  525 ,  525 ,
           525 ,  526 ,  526 ,  526 ,  526 ,  527 ,
           527 ,  527 ,  527 ,  528 ,  528 ,  528 ,
           528 ,  528 ,  528 ,  528 ,  528
};
#define ITALIANO
//#define FRANCESE
#ifdef ITALIANO
const char string_1[] PROGMEM = "R1=SCHEDA DI TARATURA";
const char string_2[] PROGMEM = "R1A=Generata il:";
const char string_3[] PROGMEM = "R1B=Ore:";
const char string_4[] PROGMEM = "R2=Parametri generali:";
const char string_5[] PROGMEM = "R3=Prodotto in uso           :";
const char string_6[] PROGMEM = "R4=Fotocellula               :";
const char string_7[] PROGMEM = "R5=Reset manuale             :";
const char string_8[] PROGMEM = "R6=Tempo di oscuramento      :";
const char string_9[] PROGMEM = "R7=Stop su errore            :";
const char string_10[] PROGMEM = "R8=Tempo stabilizzazione     :";
const char string_11[] PROGMEM = "R9=Timeout fotocellula       :";
const char string_12[] PROGMEM = "R10=Errore mancata espulsione :";
const char string_13[] PROGMEM = "R11=Tempo sincronismo contatti:";
const char string_14[] PROGMEM = "R12=Inserita";
const char string_15[] PROGMEM = "R13=Disinserita";
const char string_16[] PROGMEM = "R14=Inserito";
const char string_17[] PROGMEM = "R15=Disinserito";
const char string_18[] PROGMEM = "PP1=Parametri prodotto : ";
const char string_19[] PROGMEM = "PP2=Nome:";
const char string_20[] PROGMEM = "PP3=Programma N.        :";
const char string_21[] PROGMEM = "PP4=Sensibilità canale 1:";
const char string_22[] PROGMEM = "PP5=Sensibilità canale 2:";
const char string_23[] PROGMEM = "PP6=Velocità intercett. :";
const char string_24[] PROGMEM = "PP7=Cadenza massima     :";
const char string_25[] PROGMEM = "PP8=Ritardo espulsione  :";
const char string_26[] PROGMEM = "PP9=Durata espulsione   :";
const char string_27[] PROGMEM = "PP10=******* Termine scheda di taratura *******";
const char string_28[] PROGMEM = "DR1=REPORT DEL GIORNO: ";
const char string_29[] PROGMEM = "DR2=ORA        EVENTO";
const char string_30[] PROGMEM = "DR3=&******** Fine Monitoraggio **********";
const char string_31[] PROGMEM = "DR4=SEGNALAZIONE ERRORI";
const char string_32[] PROGMEM = "ERS=&Dispositivo spento-";
const char string_33[] PROGMEM = "ER0=Start monitor-";
const char string_34[] PROGMEM = "ER1=Errore di formato ";
const char string_35[] PROGMEM = "ER2=Entra in programmazione ";
const char string_36[] PROGMEM = "ER3=Canali rumorosi ";
const char string_37[] PROGMEM = "ER4=^Metalim ready ";
const char string_38[] PROGMEM = "ER5=Programmazione remota ";
const char string_39[] PROGMEM = "ER6=Selezionato prodotto N.";
const char string_40[] PROGMEM = "ER7=In aggiornamento";
const char string_41[] PROGMEM = "ER8=Lettura prodotto aggiornato N.";
const char string_42[] PROGMEM = "ER9=Generata nuova scheda di taratura ";
const char string_43[] PROGMEM = "ER10=Aggiornata la scheda di taratura";
const char string_44[] PROGMEM = "ER11=Test periodico ";
const char string_45[] PROGMEM = "ER12=Accesso da terminale- ";
const char string_46[] PROGMEM = "ER13=^Fine programmazione da terminale- ";
const char string_47[] PROGMEM = "ER13A=Uscito da terminale senza modifiche";
const char string_48[] PROGMEM = "ER14=!Allarmi N.:";
const char string_49[] PROGMEM = "ER15=Totale allarmi:";
const char string_50[] PROGMEM = "TP1=Totali per prodotto";
const char string_51[] PROGMEM = "TP2=Prodotto N. ";
const char string_52[] PROGMEM = "TP3=Nome: ";
const char string_53[] PROGMEM = "TP4=Allarmi : ";
const char string_54[] PROGMEM = "TP5= Pezzi prodotti: ";
const char string_55[] PROGMEM = "TP6= Totale allarmi del giorno";
#endif
#ifdef FRANCESE
const char string_1[] PROGMEM = "R1=CARTE D'ÉTALONNAGE ";
const char string_2[] PROGMEM = "R1A=Généré:";
const char string_3[] PROGMEM = "R1B=Heures:";
const char string_4[] PROGMEM = "R2=Paramètres généraux:";
const char string_5[] PROGMEM = "R3=Produit utilisé           :";
const char string_6[] PROGMEM = "R4=Photocellule              :";
const char string_7[] PROGMEM = "R5=Réinitialisation manuelle :";
const char string_8[] PROGMEM = "R6=Assombrissement           :";
const char string_9[] PROGMEM = "R7=Arrêt sur erreur          :";
const char string_10[] PROGMEM = "R8=Temps de stabilisation    :";
const char string_11[] PROGMEM = "R9=Temps mort photocellule   :";
const char string_12[] PROGMEM = "R10=Erreur non éjectée        :";
const char string_13[] PROGMEM = "R11=Temps synchronisation     :";
const char string_14[] PROGMEM = "R12=Ajouté ";
const char string_15[] PROGMEM = "R13=Eteint ";
const char string_16[] PROGMEM = "R14=Ajoutée ";
const char string_17[] PROGMEM = "R15=Eteint ";
const char string_18[] PROGMEM = "PP1=Paramètres produit :";
const char string_19[] PROGMEM = "PP2=Nom :";
const char string_20[] PROGMEM = "PP3=Programme N.        :";
const char string_21[] PROGMEM = "PP4=Sensibilité canal 1 :";
const char string_22[] PROGMEM = "PP5=Sensibilité canal 2 :";
const char string_23[] PROGMEM = "PP6=Vitesse interception:";
const char string_24[] PROGMEM = "PP7=Cadence maximale    :";
const char string_25[] PROGMEM = "PP8=Délai d'expulsion   :";
const char string_26[] PROGMEM = "PP9=Durée expulsion     :";
const char string_27[] PROGMEM = "PP10=*******  Carte d'étalonnage Terme  *******";
const char string_28[] PROGMEM = "DR1=RAPPORT DU JOUR  :";
const char string_29[] PROGMEM = "DR2=TEMPS   EVENEMENT ";
const char string_30[] PROGMEM = "DR3=&********Surveillance de fin**********";
const char string_31[] PROGMEM = "DR4=SIGNALISATION D'ERREUR ";
const char string_32[] PROGMEM = "ERS=&Appareil éteint   -";
const char string_33[] PROGMEM = "ER0=Démarrer moniteur -";
const char string_34[] PROGMEM = "ER1=Erreur de format ";
const char string_35[] PROGMEM = "ER2=Entrez la programmation";
const char string_36[] PROGMEM = "ER3=Canaux bruyants ";
const char string_37[] PROGMEM = "ER4=^Metalim prêt ";
const char string_38[] PROGMEM = "ER5=Programmation à distance ";
const char string_39[] PROGMEM = "ER6=Produit sélectionné N.";
const char string_40[] PROGMEM = "ER7=En mise à jour ";
const char string_41[] PROGMEM = "ER8=Lecture du produit mis à jour N.";
const char string_42[] PROGMEM = "ER9=Généré nouvelle carte d'étalonnage ";
const char string_43[] PROGMEM = "ER10=Carte d’ètalonnage mise à jour ";
const char string_44[] PROGMEM = "ER11=Test périodique ";
const char string_45[] PROGMEM = "ER12=Accès depuis le terminal-";
const char string_46[] PROGMEM = "ER13=^Fin de programmation depuis le terminal-";
const char string_47[] PROGMEM = "ER13A= Sortie du terminal sans modification ";
const char string_48[] PROGMEM = "ER14=!Alarmes N°:";
const char string_49[] PROGMEM = "ER15=Alarmes totales:";
const char string_50[] PROGMEM = "TP1=Totaux par produit";
const char string_51[] PROGMEM = "TP2=Produit N°";
const char string_52[] PROGMEM = "TP3=Nom: ";
const char string_53[] PROGMEM = "TP4= Alarmes : ";
const char string_54[] PROGMEM = "TP5= Piéces produites: ";
const char string_55[] PROGMEM = "TP6= Total des alarmes du jour ";
#endif
const char* const string_table[] PROGMEM  = {string_1, string_2, string_3, string_4, string_5, string_6, string_7, string_8, string_9, string_10, string_11, string_12, string_13, string_14, string_15, string_16, string_17, string_18, string_19, string_20, string_21, string_22, string_23, string_24, string_25, string_26, string_27, string_28, string_29, string_30, string_31, string_32, string_33, string_34, string_35, string_36, string_37, string_38, string_39, string_40, string_41, string_42, string_43, string_44, string_45, string_46, string_47, string_48, string_49, string_50, string_51, string_52, string_53, string_54, string_55};

B4R::Object beo1;
B4R::Object* getdata(B4R::Object* o) {
   return beo1.wrapNumber((int)pgm_read_word(data + o->toLong()));
}

B4R::Object* getdata1(B4R::Object* o) {

    strcpy_P(strx, (char*)pgm_read_word(&(string_table[o->toLong()]))); // Necessary casts and dereferencing, just copy.
  
    b4r_statica::_stringa->data = strx;
    int n=0;
    do
      n++;
    while (strx[n]!=0) ;
  
    b4r_statica::_stringa->length = n;
    return 0; 
}

  B4R::Object* findstring(B4R::Object* o) {
   // Serial.print("Findstring1111");
    long n=-1;
    B4R::Array* b =(B4R::Array*)B4R::Object::toPointer(o);
    char* testx = (char*)b->data;
    int lgt=(int)b->length;
    do
    {
      n++;
      if (n> 54)
      {
        n=0;
        break; 
      }
      if (strncmp_P(testx, (char*)pgm_read_word(&(string_table[n])),lgt)==0) break;
    } 
    while(1);
    strcpy_P(strx, (char*)pgm_read_word(&(string_table[n])));
    //Serial.println(strx);
    b4r_statica::_stringa->data = strx+lgt;
    b4r_statica::_stringa->length = strlen(strx)-lgt;
    return 0; 
}
#end if
 
Top