StratifyLib Documentation

This is the Stratify Application Library documentation. If you consider yourself an expert, you can check out the Stratify OS documentation.

Introduction

Stratify Lib is a library for Stratify OS applications that makes it easy to access hardware and other system functions (you can also use standard POSIX and C Standard Library functions if that is your style).

If you are new, it would be highly beneficial to quickly read through the naming conventions: https://github.com/StratifyLabs/StratifyLib#naming-conventions.

Here are some useful namespaces to check out:

  • hal - Hardware Abstraction Layer
  • calc - Useful software algorithms
  • draw - Drawing on an LCD
  • fmt - Common file formats
  • sys - Access to timers and files and such
  • var - Variable storage in data and strings

Here are a couple of examples to give you an idea about how things work. These are the objects used in the examples.

#include <stfy/hal.hpp> //this will include all namespace classes and add the namespace i.e. "using namespace hal;"
#include <stfy/sys.hpp>
int main(int argc, char * argv[]){
Pin p(2, 10);
Pin button(2,9);
p.init(Pin::OUTPUT); //open the port and configure pin 10 as an output
button.init(Pin::INPUT | Pin::PULLUP); //pin 9 is an input (pulled high)
//toggle p until the button is pressed
while( button.value() != 0 ){
p = false;
Timer::wait_msec(100);
p = true;
Timer::wait_msec(100);
}
return 0;
}

Here is an example of a UART loop back routine.

#include <stfy/hal.hpp>
#include <stfy/var.hpp>
int main(int argc, char * argv[]){
Uart uart(0);
int ret;
String exitCommand = "exit\n";
bool done = false;
char buffer[64];
uart.init(115200);
//loopback UART until exit is entered
while( done == false ){
if( (ret = uart.read(buffer,64)) > 0 ){
if( exitCommand == buffer ){
done = true;
}
uart.write(buffer, ret);
}
}
return 0;
}

The best way to learn is to get started: https://github.com/StratifyLabs/HelloWorld#helloworld.