Compare commits
4
Commits
75d2099655
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39f561a23f
|
||
|
|
1c241952fb
|
||
|
|
6e49b7565b
|
||
|
|
ed32bcedd2
|
Vendored
+77
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"Studuino Boilerplate": {
|
||||||
|
"prefix": "studuino_boilerplate",
|
||||||
|
"body": [
|
||||||
|
"#include <Arduino.h> // Basic header file",
|
||||||
|
"#include <Servo.h>",
|
||||||
|
"// Servomotor header file",
|
||||||
|
"#include <Wire.h>",
|
||||||
|
"// I2C device header file",
|
||||||
|
"#include <MMA8653.h> // Accelerometer header file",
|
||||||
|
"#include <MPU6050.h>",
|
||||||
|
"// Gyroscope header file",
|
||||||
|
"#include <IRremoteForStuduino.h>",
|
||||||
|
"// IR Receiver header file",
|
||||||
|
"#include <ColorSensor.h>",
|
||||||
|
"// Color Sensor header file",
|
||||||
|
"#include \"Studuino.h\" // Studuino header file",
|
||||||
|
"",
|
||||||
|
"Studuino board;",
|
||||||
|
"",
|
||||||
|
"void setup() {",
|
||||||
|
" $1",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"void loop() {",
|
||||||
|
" $2",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "Standard Studuino header includes and boilerplate"
|
||||||
|
},
|
||||||
|
"InitSensorPort": {
|
||||||
|
"prefix": "InitSensorPort",
|
||||||
|
"body": "board.InitSensorPort(${1:PORT}, ${2:TYPE});",
|
||||||
|
"description": "Initializes a sensor port."
|
||||||
|
},
|
||||||
|
"GetUltrasonicSensorValue": {
|
||||||
|
"prefix": "GetUltrasonicSensorValue",
|
||||||
|
"body": "GetUltrasonicSensorValue(${1:trigger}, ${2:echo})",
|
||||||
|
"description": "Retrieves the value of an Ultrasonic Sensor."
|
||||||
|
},
|
||||||
|
"GetGyroscopeValue": {
|
||||||
|
"prefix": "GetGyroscopeValue",
|
||||||
|
"body": "GetGyroscopeValue(${1|X_AXIS,Y_AXIS,Z_AXIS,GX_AXIS,GY_AXIS,GZ_AXIS|})",
|
||||||
|
"description": "Retrieves acceleration and angular velocity of a Gyroscope."
|
||||||
|
},
|
||||||
|
"Move": {
|
||||||
|
"prefix": "board.Move",
|
||||||
|
"body": "board.Move(${1:direction}, ${2:power}, ${3:duration}, ${4:stopMode});",
|
||||||
|
"description": "Moves DC Motors."
|
||||||
|
},
|
||||||
|
"LED": {
|
||||||
|
"prefix": "board.LED",
|
||||||
|
"body": "board.LED(${1:port}, ${2:color});",
|
||||||
|
"description": "Sets the LED color."
|
||||||
|
},
|
||||||
|
"Buzzer": {
|
||||||
|
"prefix": "board.Buzzer",
|
||||||
|
"body": "board.Buzzer(${1:pitch}, ${2:duration});",
|
||||||
|
"description": "Plays a sound on the buzzer."
|
||||||
|
},
|
||||||
|
"Servomotor": {
|
||||||
|
"prefix": "board.Servomotor",
|
||||||
|
"body": "board.Servomotor(${1:PORT}, ${2:ANGLE});",
|
||||||
|
"description": "Sets the servomotor angle."
|
||||||
|
},
|
||||||
|
"DCMotorTravelDistance": {
|
||||||
|
"prefix": "MoveCm",
|
||||||
|
"body": "// Distance = ${1:30}cm, Speed = ${2:speedVar} (ms/cm)\nboard.Move(${3:FORWARD}, ${4:POWER}, (#${1:30}*${2:speedVar}), ${5:COAST});",
|
||||||
|
"description": "Moves DC motor for a distance in cm (using #cm*Variable syntax, ensure speedVar is ms/cm)"
|
||||||
|
},
|
||||||
|
"SetDCMotorCalibration": {
|
||||||
|
"prefix": "SetDCMotorCalibration",
|
||||||
|
"body": "byte calib[] = { ${1:100}, ${2:100} };\nboard.SetDCMotorCalibration(calib);",
|
||||||
|
"description": "Sets DC Motor speed calibration."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Studuino Development Instructions
|
||||||
|
|
||||||
|
## Environment Setup
|
||||||
|
- Run `./setup.sh --with-editor` to install `arduino-cli` and `clangd`.
|
||||||
|
- **Mandatory Configuration**: Create `.arduino_config.lua` in the root with `board` and `port` settings for `Arduino-Nvim` to function.
|
||||||
|
|
||||||
|
## Development Workflow
|
||||||
|
- **Boilerplate**: Use the `studuino_boilerplate` snippet to insert required headers and the `Studuino board` instance.
|
||||||
|
- **Snippets**: Project-specific snippets are located in `.vscode/studuino.code-snippets`.
|
||||||
|
- **Build & Upload**: Use the following Neovim leader keybindings:
|
||||||
|
- `<Leader>mc`: Compile (`:InoCheck`)
|
||||||
|
- `<Leader>mu`: Upload (`:InoUpload`)
|
||||||
|
- `<Leader>mm`: Serial Monitor (`:InoMonitor`)
|
||||||
|
|
||||||
|
## Repo Structure
|
||||||
|
- **Libraries**: Custom or adapted libraries are under `/libraries/`. Key libraries used in Studuino projects include:
|
||||||
|
- `ColorSensor`, `MPU6050`, `BusIOForStuduino`, `Clock`, `Servo`, `Adafruit_CircuitPlayground`, and `IRremoteForStuduino`.
|
||||||
|
- When adding new functionality, ensure the corresponding header files are included in your sketches as shown in the boilerplate.
|
||||||
@@ -1,10 +1,16 @@
|
|||||||
#include <Studuino.h>
|
#include <Studuino.h>
|
||||||
#include <Clock.h> // Keep the complete smoke-test dependency set in clangd's database.
|
#include <Clock.h> // Keep the complete smoke-test dependency set in clangd's database.
|
||||||
|
|
||||||
|
// DC Motor Calibration (0-100)
|
||||||
|
#define M1_CALIB 100
|
||||||
|
#define M2_CALIB 100
|
||||||
|
|
||||||
Studuino board;
|
Studuino board;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
board.InitSensorPort(PORT_A0, PIDLED);
|
board.InitSensorPort(PORT_A0, PIDLED);
|
||||||
|
byte calib[] = { M1_CALIB, M2_CALIB };
|
||||||
|
board.SetDCMotorCalibration(calib);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|||||||
@@ -16,6 +16,19 @@ This repository contains the Studuino hardware definition, the legacy Studuino l
|
|||||||
- Optional `picocom` serial-monitor support.
|
- Optional `picocom` serial-monitor support.
|
||||||
- A LazyVim/Arduino-Nvim configuration template.
|
- A LazyVim/Arduino-Nvim configuration template.
|
||||||
|
|
||||||
|
## Libraries
|
||||||
|
|
||||||
|
Custom or adapted libraries are located in the `/libraries/` directory. These include:
|
||||||
|
- `ColorSensor`
|
||||||
|
- `MPU6050`
|
||||||
|
- `BusIOForStuduino`
|
||||||
|
- `Clock`
|
||||||
|
- `Servo`
|
||||||
|
- `Adafruit_CircuitPlayground`
|
||||||
|
- `IRremoteForStuduino`
|
||||||
|
|
||||||
|
When creating new programs, ensure the header files for the components you are using are properly included in your sketches. Use the provided `studuino_boilerplate` snippet to get started quickly.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Arch Linux or another Linux distribution with `bash`.
|
- Arch Linux or another Linux distribution with `bash`.
|
||||||
|
|||||||
Reference in New Issue
Block a user