Skip to content

avsa242/spin-standard-library

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Spin Standard Library

The Spin Standard Library is designed to be a general-purpose library with a wide scope of functionality, covering low-level I/O, text processing, device drivers and more for the Parallax Propeller (P8X32A) MCU. It contains a curated collection of Spin objects that have been organized and formatted with a focus on consistency and code reusability.

Usage

There are no special installation steps that need to be carried out, besides downloading this repository. The only salient step is that the library/ subdirectory should be set in FlexSpin's path, using the -I flag on the build commandline.

For example:

flexspin -I /home/myhome/spin-standard-library/library demos/com/Serial-HelloWorld.spin

API

An ongoing effort is being made to standardize the API for the various device drivers and other objects contained in the library. Manufacturers may not all utilize the same design methodologies and the interface they expose to developers may differ, but this library aims to distill all of it to a common programming interface. Essentially, once you've learned how to operate a particular device driver, all others of the same category would require minimal or no extra effort to learn.

Decriptions of the programming interface for the various classes of library can be found in the API subdirectory. At the time of this writing, they are:

  • display: Displays, e.g., OLED, LCD, VGA
  • driver-basic-structure: Describes common conventions used throughout device driver object files
  • graphics.common: Generic bitmap graphics routines common to dot-matrix type displays
  • input.encoder: Various encoders used for position input data
  • input.pointer: Various pointing devices, e.g.: mouse, trackball, trackpad
  • memory: Various memory technologies, e.g.: EEPROM, FRAM, SRAM, Flash
  • sensor.co2: Carbon dioxide sensors
  • sensor.imu: IMUs and other motion-related sensors, e.g., accelerometers, gyroscopes, magnetometers
  • sensor.power: Sensors for measuring the flow of electricity, power usage
  • sensor.temp_rh: Temperature and humidity sensors
  • signal.adc: Analog to Digital Converters
  • time: Timekeeping device drivers (hardware and emulated), e.g.: RTC
  • wireless.transceiver: RF Packet radios for sending and receiving data wirelessly

Directory structure

  • api/: Descriptions of the Application Programming Interface for each category of object.
  • library/: The library itself - this should be added to the compiler's library path (e.g. flexspin -I/path/to/spin-standard-library/library).
  • library/demos/: Basic demonstrations of drivers and other objects. Utilizes only what's necessary to demonstrate the core functionality of a driver (such as a serial terminal object to display the data). Example: a demo of a sensor will display sensor data on the terminal.
  • library/examples/: More complex demonstrations, forming rudimentary but specific applications. May utilize more objects as needed to demonstrate specific functionality (such as an OLED or LCD). For example: using accelerometer data to produce an inclinometer.
  • library/templates/: "Skeletons" of source code that can be used as a template for an application, or object.

Potential users

I don't recommend the use of this library if you're new to programming, in general. It makes assumptions about some things that an inexperienced programmer may simply not understand, and I don't have the time to maintain the library and support that level of inexperience simultaneously. I'd also hesitate to recommend it if you're looking for code of the utmost efficiency and speed. Consistency and reusability is my primary objective.

Compiler compatibility

The library is developed using FlexSpin. Some objects use features not implemented in other toolchains, such as preprocessor directives, function pointers, object pointers, et al, so will not be compatible with the Propeller Tool, OpenSpin, Brad's Spin Tool/bstc, all of which are unmaintained and in some cases closed-source. Objects in the library may even be written in such a way that the compiler feature is fundamental to the design of the object (this is particularly true with the use of function and object pointers), making it impractical to translate to other toolchains.

Currently, efforts are focused on making sure that the objects build and work when using the bytecode backend as opposed to the PASM backend, due to the size of binaries produced when using the latter. I do generally check that code at least builds when using the PASM backend.

Upon specific request, I may be able to translate to Propeller Tool-compatible source if absolutely necessary. If the source is particularly complex I may decline the request, however - sorry. Please save yourself and me the time and headache - just use FlexSpin. It's available for all major platforms and is actively maintained. Nearly every project in this library is also maintained as SPIN2 in the p2-spin-standard-library for the Propeller 2, which requires twice the time and effort, so please also keep this in mind before asking for support translating to source compatible with other tools. Thanks for understanding!

Testing

You can compile every file in the project with the following script.

./test.sh

Note that some individual drivers may (expectedly) fail to build, if they utilize preprocessor features. This will be reworked in the future.

License

This project is licensed under the MIT license.

Please note this library isn't officialy sanctioned by Parallax, Inc - it is a fork of the original spin-standard-library.

About

A curated collection of essential Spin objects

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • Propeller Spin 100.0%