- Project Overview
- Used hardware and Library
- Thread overview
- Implementation Analysis
- How to install
- Future improvements
The central concept behind the RANPW project is to create a dynamic, Tamagotchi-inspired tool enriched with a selection of games (LCatch, Pong, and LockY) and productivity applications (Cronometer and Termometer). This versatile platform encourages high modularity, enabling individuals with basic C++ knowledge to seamlessly develop and incorporate their custom apps and games. RANPW is designed to operate on the mbed NXP LPC1768 microcontroller, coupled with the mbed application board.
The 32x128 pixel LCD display serves as the primary visual interface for all interactions within the application. To achieve seamless control over the display, I've customized the C12832.h library to ensure compatibility with the project's broader software ecosystem.
The joystick plays a pivotal role in navigating through all application interfaces. Its management is facilitated through the APIs provided directly by "mbed.h," which can be accessed here.
Both potentiometers are integral to specific user interactions, with one notably enhancing gameplay in the LockY game. The control of these potentiometers is streamlined through the APIs provided by "mbed.h," as detailed here.
The LM75BD temperature sensor is utilized in the "Termometer" application to capture environmental temperature data. The sensor is integrated into the project using the LM75B.h library, with minor modifications to ensure compatibility with the Embed OS CE platform.
The MMA7660 accelerometer contributes significantly to user interactions, particularly in the Hell and Pong games. To collect data from this component, the MMA7660.h library has been employed with slight modifications to align it with the project's requirements.
At startup, RANPW initializes three distinct threads to manage various aspects of its functionality:
This thread is responsible for overseeing the entire user interface and facilitating interaction with end-users. It dynamically creates and initializes instances of all apps and games while orchestrating their display on the LCD screen. Further insights into this thread's workings can be found in the Ranpw.h and Ranpw.cpp files.
Thread 2 operates on a straightforward principle, employing basic rand() functions to introduce wait times of 1 to 5 minutes. During these intervals, it randomly decreases the pet's hunger by a value ranging from 1 to 5. Should the hunger level plummet to zero, the pet's life diminishes at varying rates—1, 2, or 3 points per minute. Conversely, if hunger surpasses 20, the pet gains 1 life point. Notably, both life and hunger levels have a cap of 25. Detailed insights into this thread's functionality are available in the live() function within Kraken.cpp.
Thread 3 operates with a clear focus on data integrity. It consistently monitors the data stored in the members of the ConcurrentData structure. This structure is vital for ensuring safe data access across multiple threads. When disparities between the stored data and in-memory data are detected, Thread 3 takes action, overwriting the data and saving the respective file in the device's internal memory.
In the process of realizing the RANPW project, I've meticulously crafted 15 different classes to lay the foundation for its functionality and modularity. Each of these components plays a specific role in the project's architecture:
This essential structure serves as the backbone for managing concurrent data access across multiple threads. It ensures data integrity and consistency, preventing conflicts and race conditions.
The DataSaver class is responsible for handling data saving and data loading operations, ensuring that changes to critical data are persistently stored in the device's internal memory.
The Ranpw class serves as the central hub for user interface management. It oversees the creation and initialization of app and game instances, orchestrates their display on the LCD screen, and manages user input via various hardware interfaces.
The Kraken class embodies the behavior and lifecycle of the virtual pet, monitoring key metrics such as hunger and life. It simulates the pet's interactions with the user.
The Bag class manages the virtual inventory system, allowing users to collect and interact with food items within the application. It enhances gameplay and engagement.
The Cronometer is a specialized application designed to provide users with a versatile stopwatch.
LCatch is one of the interactive games featured in RANPW. It provides an engaging experience where users can test their reflexes and coordination. What sets LCatch apart is its incremental speed feature, where the game progressively increases in difficulty as players successfully capture objects.
LockY is another game that offers users a unique challenge. It leverages hardware components like potentiometers for gameplay.
In Pong, player use the accelerometer as a unique input method to control the paddle and engage in the timeless challenge of bouncing a ball.
Hell is a captivating minigame tucked within the RANPW project, offering a distinctive twist on the gaming experience. Unlike other games, Hell only surfaces when the Kraken's life reaches zero, triggering the Kraken's respawn process. Distinguished by its lack of a tutorial, Hell immerses players in a realm where they need to discover how to play by hiself
This class allow users to monitor temperature levels in their environment. What sets this component apart is its ability to visualize temperature data through a graph.
All that is necessary is to download the binary available here and then insert it into the internal storage of the microcontroller
To compile it yourself, I recommend following the official embed OS CE wiki instead. In particular I recommend, once the development environment has been configured, you can chose to compile it:
- On the command line
- Using the CLion IDE
- Using the VS Code IDE
Remember that if you add something new to the project you need also to add it to the CMakeList.txt file
Enhance data security by implementing minor encryption measures for all saved data. This safeguard prevents unauthorized user modifications and ensures data integrity.
Optimize and streamline the codebase with the following refactorings:
Consider redesigning all the game components to have a common superclass, promoting code reusability and consistency among different games.
Similarly, create a superclass for apps within the project to standardize their structure and behavior, making it easier to add new apps.
An app that give the ranpw the ability to simulate a mouse, users can interact with their computer systems by controlling the mouse cursor's movement and clicks directly from RANPW.
An app that, give the script thanks to a USB stick, it allows the device, to emulate the behavior of a "Rubber Ducky.
Integrate music and sound effects into various aspects of the project to enhance the overall user experience and immersion.
Implement user settings that allow users to control music and sound effects, granting them the option to enable or disable audio as per their preference.
Design and create a 3D-printable case for the project.
Make a custom PCB to integrate all the need hardware in a more compact manner.