![]() |
firmwareSandsara
|
#include <Arduino.h>#include "SdFiles.h"#include "Motors.h"#include "Bluetooth.h"#include <Adafruit_NeoPixel.h>#include <FastLED.h>#include "WorkingArea.h"#include "Testing.h"#include "esp_int_wdt.h"#include "esp_task_wdt.h"#include "SPI.h"#include "SdFat.h"#include <math.h>#include <EEPROM.h>#include <leds.h>
Macros | |
| #define | FASTLED_ESP32_I2S true |
| #define | LED_PIN 32 |
| #define | BRIGHTNESS 255 |
| #define | LED_TYPE WS2812B |
| #define | COLOR_ORDER GRB |
Functions | |
| bool | sdExists (String) |
| esta funcion sirve para poder utilizar la funcion miembro "exists" de la libreria SdFat pero con un String como argumento. More... | |
| bool | sdRemove (String) |
| esta funcion sirve para poder utilizar la funcion miembro "remove" de la libreria SdFat pero con un String como argumento. More... | |
| int | programming (String) |
| Intenta actualizar el firmware. More... | |
| void | rebootWithMessage (String) |
| Reinicia el Esp32 pero antes escribe un mensaje por Serial. More... | |
| int | stringToArray (String, uint8_t *, int) |
| Convierte un string en un array un string de la forma x1,x2,...,xn se convierte en un array [0]=x1, [1]=x1, ...,[n-1]=xn. More... | |
| int | moveInterpolateTo (double x, double y, double distance) |
| this function is used to go from one point to another in a straight line path formed by equidistant points of 1 mm. More... | |
| void | executeCode (int) |
| void | Neo_Pixel (int) |
| uint32_t | rainbow () |
| void | FillLEDsFromPaletteColors (uint8_t) |
| void | changePalette (int pallet) |
| Change the pallette of leds. More... | |
| void | SetupTotallyRandomPalette () |
| void | SetupBlackAndWhiteStripedPalette () |
| void | SetupPurpleAndGreenPalette () |
| void | ledsFunc (void *pvParameters) |
| ledsFunc es una tarea que se corre en paralelo y que se encarga de encender los leds. More... | |
| int | run_sandsara (String playList, int orderMode) |
| int | movePolarTo (double component_1, double component_2, double couplingAngle, bool littleMovement) |
| Interpola los puntos necesarios entre el punto actual y el siguiente con el objetivo que se mueva en coordenadas polares como lo hace sisyphus. More... | |
| int | romSetPlaylist (String str) |
| actualiza el valor, en la ROM/FLASH, el nombre de la lista de reproducción. More... | |
| String | romGetPlaylist () |
| recupera el nombre de la playlist guardada en ROM More... | |
| int | romSetOrderMode (int orderMode) |
| guarda el tipo de orden de reporduccion en la memoria ROM More... | |
| int | romGetOrderMode () |
| recupera el valor correspondiente al tipo de reporduccion guardado en la memoria ROM. More... | |
| int | romSetPallete (int pallete) |
| guarda la paleta de colores en rom More... | |
| int | romGetPallete () |
| recupera, de la ROM, la ultima palleta de colores guardada. More... | |
| int | romSetSpeedMotor (int speed) |
| guarda la velocidad de Sandsara en la ROM More... | |
| int | romGetSpeedMotor () |
| recupera, de la ROM, la velocidad de Sandsara. More... | |
| int | romSetPeriodLed (int periodLed) |
| guarda el tiempo de refresco de los leds en ROM. More... | |
| int | romGetPeriodLed () |
| recupera, de la ROM, el tiempo de refresco de los leds. More... | |
| int | romSetCustomPallete (uint8_t *positions,uint8_t *red, uint8_t *green, uint8_t *blue, int numberOfColors) |
| guarda una custom pallete en la memoria ROM. More... | |
| int | romGetCustomPallete (CRGBPalette256 &pallete) |
| recupera una paleta de colores personalizada de la memoria ROM. More... | |
| int | romSetBluetoothName (String str) |
| guarda el nombre del dispositivo bluetooth. More... | |
| String | romGetBluetoothName () |
| recupera el nombre del bluetooth guardado en ROM More... | |
| int | romSetIntermediateCalibration (bool state) |
| save the variable IntermediateCalibration in ROM. More... | |
| bool | romGetIntermediateCalibration () |
| get the variable IntermediateCalibration from ROM. More... | |
| int | romSetPositionList (int pList) |
| This function save the current playlist position in ROM. More... | |
| int | romGetPositionList () |
| restore the current position in the playlist in ROM. More... | |
| int | romSetIncrementIndexPallete (bool incrementIndex) |
| guarda la variable incrementIndexPallete. More... | |
| bool | romGetIncrementIndexPallete () |
| recupera la variable incrementIndexPallete. More... | |
| int | romSetLedsDirection (bool direction) |
| stored the direction of leds in ROM. More... | |
| bool | romGetLedsDirection () |
| restored the direction of leds saved in ROM. More... | |
| int | romSetBrightness (uint8_t brightness) |
| stored the brightness of the led strip in ROM. More... | |
| int | romGetBrightness () |
| to get the brightness of the led strip from ROM. More... | |
| void | findUpdate () |
| this function find if there is a file update in SD, and if there is one the firmware is updated. More... | |
| int | orderRandom (String dirFile, int numberLines) |
| reordena las lineas del archivo dirFile de forma random en un archivo llamado RANDOM.playlist y borrar el archivo dirFile More... | |
| void | setFrom1 (int list[], int elements) |
| inicializa los valores del vector en orden ascendente empezando en 1. More... | |
| void | removeIndex (int list[], int index, int elements) |
| elimina el elemento en la posicion index del array list More... | |
| int | runFile (String fileName) |
| execute a path More... | |
| void | goHomeSpiral () |
| returns to home (0,0) on a spiral path. More... | |
| void | bluetoothThread (void *) |
| double | linspace (double init, double stop, int amount, int index) |
| realiza una interpolacion lineal entre el valor init y stop dividio en tantas partes como lo indica la variable amount. More... | |
| int | rgb2Interpolation (CRGBPalette256 &pallete, uint8_t *matrix) |
| performs an interpolation with the method of RGB^2 More... | |
| void | goCenterSpiral (bool stop) |
| returns to home (0,0) on a spiral path. More... | |
| void | goEdgeSpiral (bool stop) |
| returns to the outer end (SdFiles::DISTANCIA_MAX,0) on a spiral path. More... | |
| void | spiralGoTo (float module, float angle) |
| move to a certain position in spiral path. More... | |
| void | moveSteps (void *pvParameters) |
| mueve los motores 1 y 2. More... | |
| void | goPolar (double module, double angle) |
| void | setup () |
| void | loop () |
| void | FillLEDsFromPaletteColors (CRGBPalette256 palette, uint8_t colorIndex) |
Variables | |
| SdFat | SD |
| bool | readingSDFile = false |
| char | dataS [] |
| TMC2209Stepper | tmcMotorA |
| TMC2209Stepper | tmcMotorB |
| bool | incrementGlobal |
| double | times [] |
| int | pointerGlobal |
| int | EVERY_MILIMITERS = String(String(dataS[24]) + String(dataS[25])).toFloat() |
| Parametros de ida al centro en espiral cada EVERY_MILIMITERS en modulo de recorrido dara una vuelta. More... | |
| int | SPEED_TO_CENTER = String(String(dataS[27]) + String(dataS[28]) + String(dataS[29])).toFloat() |
| int | MAX_CHARS_PLAYLIST = String(String(dataS[31]) + String(dataS[32])).toFloat() |
| Restricciones. More... | |
| int | LEDS_OF_HALO = String(String(dataS[68]) + String(dataS[69])).toFloat() |
| int | LEDS_OF_STELLE = String(String(dataS[71]) + String(dataS[72])).toFloat() |
| int | NORMAL_CURRENT = String(String(dataS[94]) + String(dataS[95]) + String(dataS[96])).toFloat() |
| int | CURRENT_IN_CALIBRATION = String(String(dataS[98]) + String(dataS[99]) + String(dataS[100])).toFloat() |
| String | playListGlobal |
| String | bluetoothNameGlobal |
| int | orderModeGlobal |
| int | speedMotorGlobal |
| int | ledModeGlobal |
| int | periodLedsGlobal |
| bool | ceroZoneGlobal |
| bool | ledsOffGlobal = false |
| bool | rewindPlaylist = false |
| bool | incrementIndexGlobal = true |
| String | currentProgramGlobal |
| String | nextProgramGlobal |
| String | currentPlaylistGlobal |
| int | currentPositionListGlobal |
| int | delayLeds |
| int | pListFileGlobal |
| bool | changePositionList |
| bool | changeProgram |
| bool | stopProgramChangeGlobal = true |
| bool | stop_boton |
| bool | intermediateCalibration = false |
| bool | firstExecution |
| bool | availableDeceleration = false |
| bool | turnOnLeds = false |
| bool | ledsDirection |
| bool | pauseModeGlobal = false |
| bool | suspensionModeGlobal = false |
| bool | startMovement = false |
| long | q1StepsGlobal |
| long | q2StepsGlobal |
| double | distanceGlobal |
| bool | speedChangedMain = false |
| String | changedProgram |
| int | changedPosition |
| bool | lastPoint = false |
| int | tracksPlayed = 0 |
| CRGBPalette16 | NO_SD_PALLETE |
| CRGBPalette16 | UPTADATING_PALLETE |
| CRGBPalette16 | CALIBRATING_PALLETE |
| CRGBPalette16 | SDEMPTY_PALLETE |
| CRGBPalette256 | customPallete |
| CRGBPalette256 | pallette1 |
| CRGBPalette256 | pallette2 |
| CRGBPalette256 | pallette3 |
| CRGBPalette256 | pallette4 |
| CRGBPalette256 | pallette5 |
| CRGBPalette256 | pallette6 |
| CRGBPalette256 | pallette7 |
| CRGBPalette256 | pallette8 |
| CRGBPalette256 | pallette9 |
| CRGBPalette256 | pallette10 |
| CRGBPalette256 | pallette11 |
| CRGBPalette256 | pallette12 |
| CRGBPalette256 | pallette13 |
| CRGBPalette256 | pallette14 |
| CRGBPalette256 | pallette15 |
| Motors | Sandsara |
| Bluetooth | BluetoothSand |
| int | errorCode |
| int | NUM_LEDS |
| CRGB | leds [MAX_NUMBERLEDS] |
| unsigned long | timeLeds |
| uint8_t | startIndex = 0 |
| bool | productType |
| TaskHandle_t | Task1 |
| TaskHandle_t | Task2 |
| TaskHandle_t | motorsTask |
| WorkingArea | haloCalib |
| Testing | haloTest |
| bool | readingBrightness = false |
| double | maxPathSpeedGlobal |
| long | maxStepsGlobal |
| #define BRIGHTNESS 255 |
| #define COLOR_ORDER GRB |
| #define FASTLED_ESP32_I2S true |
| #define LED_PIN 32 |
| #define LED_TYPE WS2812B |
| void bluetoothThread | ( | void * | ) |
| void changePalette | ( | int | pallet | ) |
Change the pallette of leds.
| pallet | indicates the index pallete to be choosed. |
| void executeCode | ( | int | ) |
| void FillLEDsFromPaletteColors | ( | uint8_t | ) |
| void FillLEDsFromPaletteColors | ( | CRGBPalette256 | palette, |
| uint8_t | colorIndex | ||
| ) |
| void findUpdate | ( | ) |
this function find if there is a file update in SD, and if there is one the firmware is updated.
| void goCenterSpiral | ( | bool | stop | ) |
returns to home (0,0) on a spiral path.
| void goEdgeSpiral | ( | bool | stop | ) |
returns to the outer end (SdFiles::DISTANCIA_MAX,0) on a spiral path.
| void goHomeSpiral | ( | ) |
returns to home (0,0) on a spiral path.
| void goPolar | ( | double | module, |
| double | angle | ||
| ) |
| void ledsFunc | ( | void * | pvParameters | ) |
ledsFunc es una tarea que se corre en paralelo y que se encarga de encender los leds.
| double linspace | ( | double | init, |
| double | stop, | ||
| int | amount, | ||
| int | index | ||
| ) |
realiza una interpolacion lineal entre el valor init y stop dividio en tantas partes como lo indica la variable amount.
| init | es el valor inicial de la interpolacion. |
| stop | es el valor final de la interpolacion. |
| amount | es la cantidad de divisiones que va a tener la linea. |
| index | es la posicion correspondiente a cada division en la linea, el index 0 representa el valor init. |
| void loop | ( | ) |
| int moveInterpolateTo | ( | double | x, |
| double | y, | ||
| double | distance | ||
| ) |
this function is used to go from one point to another in a straight line path formed by equidistant points of 1 mm.
| x | X axis coordinate of the target point, measured in milimeters. |
| y | Y axis coordinate of the target point, measured in milimeters. |
| distance | is the distance between the current point and the target point. |
| int movePolarTo | ( | double | component_1, |
| double | component_2, | ||
| double | couplingAngle, | ||
| bool | littleMovement | ||
| ) |
Interpola los puntos necesarios entre el punto actual y el siguiente con el objetivo que se mueva en coordenadas polares como lo hace sisyphus.
| component_1 | valor en el eje z polar, medido en milimetros. |
| component_2 | valor en el eje theta polar, medido en radianes. |
| couplingAngle | es el angulo que se va a rotar el punto con coordenadas polares component_1, component_2 (modulo y angulo, respectivamente). |
====comprobar si se desea cambiar de archivo o suspender o cambiar playlist u orden====
| void moveSteps | ( | void * | pvParameters | ) |
mueve los motores 1 y 2.
La velocidad de los motores se ajusta dependiendo de la distancia a recorrer del punto inicial al final, con la intencion de que la velocidad a la que viaje la esfera sea una velocidad constante. Si la velocidad de los motores es constante, la velocidad a la que se mueve la esfera no lo va a ser debido a la geometria del mecanismo. Cada vez que se mueve la posicion a la que se movio se guarda como la posicion actual del robot.
| q1_steps | es el numero de pasos que va a girar el motor correspondiente al angulo q1. |
| q2_steps | es el numero de pasos que va a girar el motor correspondiente al angulo q2. |
| distance | es la distancia que va a recorrer entre el punto actual y el punto despues del movimiento. |
| void Neo_Pixel | ( | int | ) |
| int orderRandom | ( | String | dirFile, |
| int | numberLines | ||
| ) |
reordena las lineas del archivo dirFile de forma random en un archivo llamado RANDOM.playlist y borrar el archivo dirFile
| dirFile | es la direccion del archivo a ordenar ej. "/lista.txt" |
| numberLines | es el numero de lineas que contiene el archivo |
| int programming | ( | String | name | ) |
Intenta actualizar el firmware.
| uint32_t rainbow | ( | ) |
| void rebootWithMessage | ( | String | reason | ) |
Reinicia el Esp32 pero antes escribe un mensaje por Serial.
| void removeIndex | ( | int | list[], |
| int | index, | ||
| int | elements | ||
| ) |
elimina el elemento en la posicion index del array list
| list | es el array que se va a modificar. |
| index | la posicion del elemento que se desea quitar. |
| int rgb2Interpolation | ( | CRGBPalette256 & | pallete, |
| uint8_t * | matrix | ||
| ) |
performs an interpolation with the method of RGB^2
| String romGetBluetoothName | ( | ) |
recupera el nombre del bluetooth guardado en ROM
| int romGetBrightness | ( | ) |
to get the brightness of the led strip from ROM.
| int romGetCustomPallete | ( | CRGBPalette256 & | pallete | ) |
recupera una paleta de colores personalizada de la memoria ROM.
| pallete | es la paleta que se recupera de la rom. |
| bool romGetIncrementIndexPallete | ( | ) |
recupera la variable incrementIndexPallete.
| bool romGetIntermediateCalibration | ( | ) |
get the variable IntermediateCalibration from ROM.
| bool romGetLedsDirection | ( | ) |
restored the direction of leds saved in ROM.
| int romGetOrderMode | ( | ) |
recupera el valor correspondiente al tipo de reporduccion guardado en la memoria ROM.
| int romGetPallete | ( | ) |
recupera, de la ROM, la ultima palleta de colores guardada.
| int romGetPeriodLed | ( | ) |
recupera, de la ROM, el tiempo de refresco de los leds.
| String romGetPlaylist | ( | ) |
recupera el nombre de la playlist guardada en ROM
| int romGetPositionList | ( | ) |
restore the current position in the playlist in ROM.
| int romGetSpeedMotor | ( | ) |
recupera, de la ROM, la velocidad de Sandsara.
| int romSetBluetoothName | ( | String | str | ) |
guarda el nombre del dispositivo bluetooth.
| str | corresponde al nombre del bluetooth. |
| int romSetBrightness | ( | uint8_t | brightness | ) |
stored the brightness of the led strip in ROM.
| brightness | is the value to be stored. |
| int romSetCustomPallete | ( | uint8_t * | positions, |
| uint8_t * | red, | ||
| uint8_t * | green, | ||
| uint8_t * | blue, | ||
| int | numberOfColors | ||
| ) |
guarda una custom pallete en la memoria ROM.
| positions | es la posicion del color en la paleta de colores va de 0 a 255. |
| red | es un array que contiene los valores de Red de las posiciones en la paleta de colores. |
| green | es un array que contiene los valores de green de las posiciones en la paleta de colores. |
| blue | es un array que contiene los valores de blue de las posiciones en la paleta de colores. |
| int romSetIncrementIndexPallete | ( | bool | incrementIndex | ) |
guarda la variable incrementIndexPallete.
| incrementIndex | es el valor que se va a guardar. |
| int romSetIntermediateCalibration | ( | bool | state | ) |
save the variable IntermediateCalibration in ROM.
| state | is the value to be saved in ROM. |
| int romSetLedsDirection | ( | bool | direction | ) |
stored the direction of leds in ROM.
| direction | is the value to be stored. |
| int romSetOrderMode | ( | int | orderMode | ) |
guarda el tipo de orden de reporduccion en la memoria ROM
| orderMode | el valor que corresponde al orden de reproduccion que va a ser almacenado en ROM. |
| int romSetPallete | ( | int | pallete | ) |
guarda la paleta de colores en rom
| pallete | es un numero entero que indica la paleta de colres actual |
| int romSetPeriodLed | ( | int | periodLed | ) |
guarda el tiempo de refresco de los leds en ROM.
| periodLed | es el tiempo de refresco de los leds, medido en milisegundos. |
| int romSetPlaylist | ( | String | str | ) |
actualiza el valor, en la ROM/FLASH, el nombre de la lista de reproducción.
| str | es la dirección en la SD de la lista de reproducción, ejemplo "/animales.playlist". |
| int romSetPositionList | ( | int | pList | ) |
This function save the current playlist position in ROM.
| pList | is the currente position to be saved. |
| int romSetSpeedMotor | ( | int | speed | ) |
guarda la velocidad de Sandsara en la ROM
| speed | es la velocidad en milimetros por segundo de Sandsara. |
| int run_sandsara | ( | String | playList, |
| int | orderMode | ||
| ) |
| playlist | the name of playlist to be executed, e.g. "/animales.playlist" |
| orderMode | the orden that files will be executed 1, files will be reproduced in descending order according to playlist. 2, All files in SD will be reproduced in a determined order. |
| int runFile | ( | String | fileName | ) |
execute a path
| dirFile,path | direction in SD. |
| bool sdExists | ( | String | ) |
esta funcion sirve para poder utilizar la funcion miembro "exists" de la libreria SdFat pero con un String como argumento.
| bool sdRemove | ( | String | ) |
esta funcion sirve para poder utilizar la funcion miembro "remove" de la libreria SdFat pero con un String como argumento.
| void setFrom1 | ( | int | list[], |
| int | elements | ||
| ) |
inicializa los valores del vector en orden ascendente empezando en 1.
| list | es el array que se desea inicializar. |
| elements | es la cantidad de elementos que va a contener el array. |
| void setup | ( | ) |
| void SetupBlackAndWhiteStripedPalette | ( | ) |
| void SetupPurpleAndGreenPalette | ( | ) |
| void SetupTotallyRandomPalette | ( | ) |
| void spiralGoTo | ( | float | module, |
| float | angle | ||
| ) |
move to a certain position in spiral path.
| int stringToArray | ( | String | str, |
| uint8_t * | array, | ||
| int | n | ||
| ) |
Convierte un string en un array un string de la forma x1,x2,...,xn se convierte en un array [0]=x1, [1]=x1, ...,[n-1]=xn.
| str | Es el string que se desea convertir. |
| array | Es el array donde se van a guardar los valores del string |
| n | Es el numero de elementos que tiene el string |
| bool availableDeceleration = false |
| String bluetoothNameGlobal |
| Bluetooth BluetoothSand |
| CRGBPalette16 CALIBRATING_PALLETE |
| bool ceroZoneGlobal |
| int changedPosition |
| String changedProgram |
| bool changePositionList |
| bool changeProgram |
| int CURRENT_IN_CALIBRATION = String(String(dataS[98]) + String(dataS[99]) + String(dataS[100])).toFloat() |
| String currentPlaylistGlobal |
| int currentPositionListGlobal |
| String currentProgramGlobal |
| CRGBPalette256 customPallete |
| char dataS[] |
| int delayLeds |
| double distanceGlobal |
| int errorCode |
Parametros de ida al centro en espiral cada EVERY_MILIMITERS en modulo de recorrido dara una vuelta.
| bool firstExecution |
| WorkingArea haloCalib |
| Testing haloTest |
| bool incrementGlobal |
| bool incrementIndexGlobal = true |
| bool intermediateCalibration = false |
| bool lastPoint = false |
| int ledModeGlobal |
| CRGB leds[MAX_NUMBERLEDS] |
| bool ledsDirection |
| bool ledsOffGlobal = false |
| double maxPathSpeedGlobal |
| long maxStepsGlobal |
| TaskHandle_t motorsTask |
| String nextProgramGlobal |
| CRGBPalette16 NO_SD_PALLETE |
| int NUM_LEDS |
| int orderModeGlobal |
| CRGBPalette256 pallette1 |
| CRGBPalette256 pallette10 |
| CRGBPalette256 pallette11 |
| CRGBPalette256 pallette12 |
| CRGBPalette256 pallette13 |
| CRGBPalette256 pallette14 |
| CRGBPalette256 pallette15 |
| CRGBPalette256 pallette2 |
| CRGBPalette256 pallette3 |
| CRGBPalette256 pallette4 |
| CRGBPalette256 pallette5 |
| CRGBPalette256 pallette6 |
| CRGBPalette256 pallette7 |
| CRGBPalette256 pallette8 |
| CRGBPalette256 pallette9 |
| bool pauseModeGlobal = false |
| int periodLedsGlobal |
| String playListGlobal |
| int pListFileGlobal |
| int pointerGlobal |
| bool productType |
| long q1StepsGlobal |
| long q2StepsGlobal |
| bool readingBrightness = false |
| bool readingSDFile = false |
| bool rewindPlaylist = false |
| Motors Sandsara |
| SdFat SD |
| CRGBPalette16 SDEMPTY_PALLETE |
| bool speedChangedMain = false |
| int speedMotorGlobal |
| uint8_t startIndex = 0 |
| bool startMovement = false |
| bool stop_boton |
| bool stopProgramChangeGlobal = true |
| bool suspensionModeGlobal = false |
| TaskHandle_t Task1 |
| TaskHandle_t Task2 |
| unsigned long timeLeds |
| double times[] |
| TMC2209Stepper tmcMotorA |
| TMC2209Stepper tmcMotorB |
| int tracksPlayed = 0 |
| bool turnOnLeds = false |
| CRGBPalette16 UPTADATING_PALLETE |