LogoLogo
v7.0.0
v7.0.0
  • TotalCross Overview
  • TotalCross Javadoc
  • TotalCross Changelog
  • Roadmap
  • Documentation
    • Getting Started
      • First embedded project with TotalCross
    • Components
      • Accordion
      • Aligned Labels
      • Button
      • Check
      • ComboBox
      • Dynamic Scroll
      • Edit
      • Floating Button
      • Gpiod
      • Grid
      • GridContainer
      • Image
      • ImageControl
      • ImageList
      • Label
      • Material Icons
      • Material Window
      • MessageBox
      • Multi Edit
      • Progress Bar
      • Progress Box
      • Radio
      • Radio Group
      • Scroll Container
      • Side Menu
      • Slider
      • Sliding Window
      • Spin List
      • Spinner
      • Switch
      • Tabbed Container
      • Velocimeter
    • APIs
      • API Overview
      • API Rest
      • Asynchronous Task
      • Camera
      • Control
        • Main Window
        • Window
        • Container
      • GPS
      • HTTPS and SSL
      • JSON
      • Maps
        • Maps - Deprecated
        • Static Map
      • Material Design Standards
      • Ninepath
      • Notifications
      • PrinterManager
      • Push Notification Firebase
      • Scanner
      • SOAP
      • Socket
      • SocketServer
      • SQLite Encryption
      • QR Code Generator
      • totalcross.sys
      • Youtube API
    • Creating an Issue
    • Contributing
      • Branch workflow
      • Writing documentation
    • Guides
      • App Architecture
        • Suggested Architecture
        • Why do Design Patterns help with the application's organization?
          • MVC Architecture Pattern
          • Template Pattern
          • Data Persistence: DAO Pattern.
        • Separation of concepts: What is the best way to create UI interfaces?
        • Positioning
          • Manual Positioning
        • Relative Positioning
        • Best practices to improve project maintenance
      • Device Simulator
      • Package your app from scratch
        • TotalCross SDK
        • Environment Variables in IDE
          • Eclipse
          • IntelliJ
        • Deploy your app with a dependecy TC
        • Deploy iOS
          • Using Development certificate to test your apps
      • Understanding TotalCross for Linux ARM
      • Running C++ applications with TotalCross
      • Web Services
    • Miscelaneous
      • Java JDK 8
      • Maven
      • Installing Visual Studio Code
    • FAQ
      • IMEI in Android 10
Powered by GitBook
On this page
  • Introduction
  • Requirements
  • Guide
  • Discover VS Code plugin
  • Getting your Hello World App even more Cooler
  • How to deploy
  • After basics
  • See more
  • References

Was this helpful?

  1. Documentation
  2. Guides

Understanding TotalCross for Linux ARM

TotalCross now supports embedded systems!

PreviousUsing Development certificate to test your appsNextRunning C++ applications with TotalCross

Last updated 4 years ago

Was this helpful?

Introduction

See at this guide:

  • Discover plugin for VS Code;

  • Getting your Hello World App cooler;

  • How to deploy;

  • After basics;

Requirements

Complete the Getting Started:

The following electronic components are also required:

  • Raspberry Pi 3;

  • 7x jumpers male-female;

  • Protoboard;

  • LED RGB module (or common 4 pins LED RGB);

  • Push-button module (or common push-button).

In order to execute Gpiod methods at your embedded device, you will also need to have the libgpiod-dev package installed in your board. You can do that by entering the following command at the device's terminal:

$ sudo apt-get install libgpiod-dev

Guide

Discover VS Code plugin

Step 1: open VS Code console (CTRL + Shift + P) and type TotalC… autocomplete should help!

Step 2: select TotalCross: Create new Project;

Step 3: create a folder called HelloWorld and select it;

Step 4: GroupId will be com.totalcross;

Step 5: ArtifactId will be HelloWorld;

Step 6: select the latest version of TotalCross SDK and -linux-arm platform;

Step 7: openRunHelloWorldApplication.java and click Run (IDE). The result should be:

Step 8: watch the integrated simulator!

The following project deals with the control of an RGB LED with user interface buttons and a pin reset button!

Step 1: follow the schematic:

Step 2: to work with pin logic after public class HelloWorld extends MainWindow { add:

// Integers to store pin numbers
private int    R = 4, G = 17, B = 27, pushButton = 18;
// Integers to store state of each LED pin, 0 (LOW) and 1 (HIGH)
private int    sttR, sttG, sttB;
// Buttons to control colors 
private Button btnR, btnG, btnB;

If you need to work with different pinouts check the manufacturer manual!

Step 3: at HelloWorld.java in initUI() code add:

// Label helloWorld made on project creation
Label helloWorld = new Label("Hello World!");
// Change the position of label on the Y axis, with TOP (beginning of Y) + a fill of 20
add(helloWorld, CENTER, TOP + 20);

Step 4: then, board setup:

// Board Setup
GpiodChip gpioChip = GpiodChip.open(0);
GpiodLine pinR = gpioChip.line(R);
GpiodLine pinG = gpioChip.line(G);
GpiodLine pinB = gpioChip.line(B);
GpiodLine pinPushButton = gpioChip.line(pushButton);

Step 5: pins setup:

// Set LED pins as outputs and default value sttX
pinR.requestOutput("CONSUMER",sttR);
pinG.requestOutput("CONSUMER",sttG);
pinB.requestOutput("CONSUMER",sttB);
// Set Reset pin as input
pinPushButton.requestInput("CONSUMER");

Step 6: the red button:

// The TotalCross button:
btnR = new Button("R");                                       // Button instantiation
                                                              // without text
btnR.setBackColor(Color.RED);                                 // Set background color (red)
btnR.addPressListener(new PressListener() {                   // Press event listener
    @Override
    public void controlPressed(ControlEvent controlEvent) {
        sttR = 1 - sttR;                                      // Invert pin state 
        pinR.setValue(sttR);                                  // Set value (HIGH or LOW)
    }
});
add(btnR, CENTER - 70, AFTER + 40);                           // To make horizontally aligned 
                                                              // buttons in the 'RGB' sequence,
                                                              // take the center reference and 
                                                              // decrease 70 to place the 
                                                              // leftmost R. In the Y axis just
                                                              // take the reference of the
                                                              // previous component and add 40

Step 7: and the other buttons:

btnG = new Button("G");
btnG.setBackColor(Color.GREEN);
btnG.addPressListener(new PressListener() {
    @Override
    public void controlPressed(ControlEvent controlEvent) {
        sttG = 1 - sttG;                                      // Pay attention to change pin!!!
        pinG.setValue(sttG);
    }
});
add(btnG, CENTER, SAME);                                      // The green button will be 
                                                              // placed at the center and in 
                                                              // the same line of previous 
                                                              // button

btnB = new Button("B");
btnB.setBackColor(Color.BLUE);
btnB.addPressListener(new PressListener() {
    @Override
    public void controlPressed(ControlEvent controlEvent) {
        sttB = 1 - sttB;                                       // Pay attention to change pin!!!
        pinB.setValue(sttB);      
    }
});
add(btnB, CENTER + 70, SAME);                                  // The last button will be placed 
                                                               // to the right of the center.

Step 8: finally we use a thread to check the state of the reset button:

// A thread will be used to check every 20 ms, if the reset button has been pressed: if yes then 
// the pin state goes to LOW
new Thread() {
    @Override
    public void run() {
        while(true){
            if(pinPushButton.getValue() == 1) {
                sttG = 1 - sttG;
                sttR = 1 - sttR;
                sttB = 1 - sttB;
                pinR.setValue(sttR);
                pinG.setValue(sttG);
                pinB.setValue(sttB);
            }
            Vm.sleep(100);
        } 
    }
}.start();

Step 9: run RunHelloWorldApplication.java again and watch the results!

How to deploy

Step 1: open VS Code console (CTRL + Shift + P) and select TotalCross: Deploy

Step 2: a second dialog box will appear and just fill in the board's information:

Step 3: see the results in screen or VNC

After basics

See more

References

A quick way to start using TotalCross is installing the .

Getting your Hello World App even more Cooler

View fully code

This was the beginning of application development for TotalCross embedded systems, how about taking a look at and seeing all that can be done? See dashboard made especially for Web Summit 2019:

Are you interested in development with embedded systems? Contact us via !

🥶
😅
Getting Started
TotalCross extension for VS Code
here
TCSample
Telegram
Fritzing
Click to expand
Click to expand
Bruno Muniz, Lucas Galvanini e Pedro Lyra no WebSummit