IHope
Posts: 1
Joined: Mon Oct 16, 2017 12:36 pm

Pasring a layout file and creating a display

Mon Oct 16, 2017 12:59 pm

Hi all,

So I'm working on a project that requires me to use some kind of embedded device that recieves a layout file (XML, Json, etc.), parses it, and creates a simple display on a touchscreen (some simple buttons with text on them mostly). If a button on the screen is hit, the device sends a message back to the computer basically saying what was hit and what to display next. I know this is very possible and relatively easy with an OS but the device needs to be bare metal for requirement reasons.

I guess my main question is how easy would it be to integrate a parser into a baremetal pi? I know Ultibo already has a ton of work done in respect to working with peripherals so I might use that as a jumping off point. All answers and advice are greatly appreactiated! Thank you :)

User avatar
Ultibo
Posts: 158
Joined: Wed Sep 30, 2015 10:29 am
Location: Australia
Contact: Website

Re: Pasring a layout file and creating a display

Mon Oct 16, 2017 11:44 pm

IHope wrote:
Mon Oct 16, 2017 12:59 pm
So I'm working on a project that requires me to use some kind of embedded device that recieves a layout file (XML, Json, etc.), parses it, and creates a simple display on a touchscreen (some simple buttons with text on them mostly). If a button on the screen is hit, the device sends a message back to the computer basically saying what was hit and what to display next.
The whole concept is almost ideally suited to Ultibo, not only do we have drivers for the official 7" touchscreen there is also support for some other common displays and both XML and JSON classes are included with the Free Pascal RTL so they are available to use in Ultibo projects.
Ultibo.org | Make something amazing
https://ultibo.org

Threads, multi-core, OpenGL, Camera, FAT, NTFS, TCP/IP, USB and more in 3MB with 2 second boot!

User avatar
Gavinmc42
Posts: 3630
Joined: Wed Aug 28, 2013 3:31 am

Re: Pasring a layout file and creating a display

Tue Oct 17, 2017 2:07 am

Have not done any XML, Json, might have to look at that.

Aggpas has a SVG parser and OpenVG works in Ultibo, have not tried Aggpas yet.
UI's done by HTML, CCS, SVG would be a web tech way to make displays.

Simple web UI - episode 6
https://ultibo.org/make/
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

LdB
Posts: 1209
Joined: Wed Dec 07, 2016 2:29 pm

Re: Pasring a layout file and creating a display

Tue Oct 17, 2017 3:43 am

The question is very strange, you build a parser the same way whether you have an O/S or baremetal.
You have a clump of data that you parse to turn into something meaningful, it is no more difficult
or different in baremetal.

Also technically from your description you are designing a template system or menu system not really
a driver. To illustrate the point what you are describing was done for menu years in batch file menu
systems on DOS. When the process gets more advanced and you do part of the processing yourself
rather than sending it all back it becomes known as scripting. If you have ever played with Quake MOD
files or Unity you would know what that looks like.

The basics are simple you are going to have the template data either bound to inside the executable
image file or you will load it from some drive. That is an operational thing and not really relevant to the
system operation. You will have a node tree of actions and data.

When you arrive at any node you execute what the data says and you setup the new node pointers.
When you get a match to any of the action node pointers you jump to that node. In your case the
action node is going to be a key character. You haven't given much detail but lets build a basic C
node structure on what you have said and what your template would look like.

Code: Select all

// Lets define a maximum action a node can have
#define MAXACTION 8

// Lets define an action function pointer
// In the case given action will be to send a specific command character back
type void (*ActionPtr) (void); 

// Now we need a forward declare to a full node 
// Because each action node will need to know what full node it should load
typedef NODE* PNODE;

// Lets define an action node which is an action ptr and the key to cause it and the next node
typedef struct _ACTION_NODE {
    ActionPtr action;                                       // Action to do when jumping to this node
    char          key;                                      // Key press to cause the jump
    PNODE nextNode;                                         // Next full node to load after jump
} ACTION_NODE;

// NOW lets define a full node which is an array of many action nodes
typedef struct _NODE {
    int actionNodes;                        // Number of actions nodes defined on this node in the following array
   ACTION_NODE actionArray [ MAXACTION];    // The actionnode  array (groups of action and keys)
} NODE;

// Now we make the parse function for any NODE to look for a match for given key
// We pass back the new node we have moved to
PNODE Parse ( NODE* theNode, char keyToParse){
        for (int i = 0; i < theNode->actionNodes; i++){            // For each action in node
              if ( keyToParse == theNode.actionArray[i].key)      // Key matches an action node character
              {                             
                     theNode.actionArray[i].action();              // Execute the node action (would change screen probably)                 
                    return theNode.actionArray[i].nextNode;        // We will move to the action nodes next full NODE           
              }     
        }
        return theNode;		                                   // No match in parser so stay on same node
}

So there is the operational part of what you describe and it required no O/S at all.
You can load up the Node structure from a text file (DOS batch menus did that) XML, Database, Binary or whatever file you want that has nothing to do with the operation of the template system.

Return to “Bare metal, Assembly language”