Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Install gif-pros and update programming skills
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyflameWarrior committed Feb 24, 2024
1 parent 6c60863 commit f2b3788
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 28 deletions.
Binary file added firmware/gif-pros.a
Binary file not shown.
59 changes: 59 additions & 0 deletions include/gif-pros/gifclass.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pragma once
#include "main.h"
#include "gifdec.h"

/**
* MIT License
* Copyright (c) 2019 Theo Lemay
* https://github.com/theol0403/gif-pros
*/

class Gif {

public:

/**
* Construct the Gif class
* @param fname the gif filename on the SD card (prefixed with /usd/)
* @param parent the LVGL parent object
*/
Gif(const char* fname, lv_obj_t* parent);

/**
* Destructs and cleans the Gif class
*/
~Gif();

/**
* Deletes GIF and frees all allocated memory
*/
void clean();

private:

gd_GIF* _gif = nullptr; // gif decoder object
void* _gifmem = nullptr; // gif file loaded from SD into memory
uint8_t* _buffer = nullptr; // decoder frame buffer

lv_color_t* _cbuf = nullptr; // canvas buffer
lv_obj_t* _canvas = nullptr; // canvas object

pros::task_t _task = nullptr; // render task

/**
* Cleans and frees all allocated memory
*/
void _cleanup();

/**
* Render cycle, blocks until loop count exceeds gif loop count flag (if any)
*/
void _render();

/**
* Calls _render()
* @param arg Gif*
*/
static void _render_task(void* arg);

};
58 changes: 58 additions & 0 deletions include/gif-pros/gifdec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef GIFDEC_H
#define GIFDEC_H

#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

#define BYTES_PER_PIXEL 4

typedef struct gd_Palette {
int size;
uint8_t colors[0x100 * 3];
} gd_Palette;

typedef struct gd_GCE {
uint16_t delay;
uint8_t tindex;
uint8_t disposal;
int input;
int transparency;
} gd_GCE;

typedef struct gd_GIF {
FILE *fp;
off_t anim_start;
uint16_t width, height;
uint16_t depth;
uint16_t loop_count;
gd_GCE gce;
gd_Palette *palette;
gd_Palette lct, gct;
void (*plain_text)(
struct gd_GIF *gif, uint16_t tx, uint16_t ty,
uint16_t tw, uint16_t th, uint8_t cw, uint8_t ch,
uint8_t fg, uint8_t bg
);
void (*comment)(struct gd_GIF *gif);
void (*application)(struct gd_GIF *gif, char id[8], char auth[3]);
uint16_t fx, fy, fw, fh;
uint8_t bgindex;
uint8_t *canvas, *frame;
} gd_GIF;

gd_GIF *gd_open_gif(FILE *fp);
int gd_get_frame(gd_GIF *gif);
void gd_render_frame(gd_GIF *gif, uint8_t *buffer);
void gd_rewind(gd_GIF *gif);
void gd_close_gif(gd_GIF *gif);

#ifdef __cplusplus
}
#endif

#endif /* GIFDEC_H */
17 changes: 17 additions & 0 deletions project.pros
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@
"user_files": [],
"version": "0.5.0-rc.5"
},
"gif-pros": {
"location": "C:\\Users\\jibo2\\AppData\\Roaming\\PROS\\templates\\gif-pros@2.1.1",
"metadata": {
"origin": "local"
},
"name": "gif-pros",
"py/object": "pros.conductor.templates.local_template.LocalTemplate",
"supported_kernels": "^3.2.0",
"system_files": [
"include\\gif-pros\\gifdec.h",
"firmware\\gif-pros.a",
"include\\gif-pros\\gifclass.hpp"
],
"target": "v5",
"user_files": [],
"version": "2.1.1"
},
"kernel": {
"location": "C:\\Users\\korak\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.0",
"metadata": {
Expand Down
34 changes: 16 additions & 18 deletions src/autonomous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void autonomous() {
case 3:
// Left Side Half AWP
controller.print(0, 0, "Left Elims Auton");
chassis.setPose(-48 - (7 / 2), -60, 135); // X, Y, Heading (degrees)
chassis.setPose(-48 - (7.0 / 2), -60, 135); // X, Y, Heading (degrees)
//ToggleVerticalPneumaticWings();
pros::delay(250);
chassis.turnTo(0, -60, 2000);
Expand All @@ -131,7 +131,7 @@ void autonomous() {
case 4:
// in progress in-depth auton
controller.print(0, 0, "Right Elims Auton");
chassis.setPose(-48 - (7 / 2), -60, 135); // X, Y, Heading (degrees)
chassis.setPose(-48 - (7.0 / 2), -60, 135); // X, Y, Heading (degrees)
ToggleVerticalPneumaticWings();
chassis.turnTo(0, -18, 2000);
ToggleVerticalPneumaticWings();
Expand All @@ -155,22 +155,6 @@ void autonomous() {
chassis.setPose(0, 0, 0); // X, Y, Heading (degrees)
break;
case 7:
// Currently curves the robot to push a triball into the goal
controller.print(0, 0, "Programming Skills - Makhi Version");
/*
chassis.setPose(-41.75, -64.975, 0); // X, Y, Heading (degrees)
chassis.follow(init_to_goal_txt, 1, 5000);
*/
// chassis.setPose(-34.5, -64.5, 330); // Guide
// chassis.turnTo(-60, -24, 5000);


// Against line
ToggleVerticalPneumaticWings();
KickerMotor.move(127);
controller.print(1, 0, "Skills Complete");
break;
case 8:
// Currently gets the kicker into position
controller.print(0, 0, "Programming Skills - Ajibola Version");
chassis.setPose(-39.75, -64.975, 0); // X, Y, Heading (degrees)
Expand All @@ -194,6 +178,20 @@ void autonomous() {
// KickerMotor.move(127);
// pros::delay(45000);

controller.print(1, 0, "Skills Complete");
break;
case 8:
// Currently curves the robot to push a triball into the goal
controller.print(0, 0, "Programming Skills - Makhi Version");

chassis.setPose(-72 + 26.5, -60, 133); // X, Y, Heading (degrees)
chassis.moveToPose(-60 + 5, -24 + 24, 180, 2500, {.forwards = false, .chasePower = 8});
chassis.waitUntilDone();
chassis.setPose(-72 + 26.5, -29.25, 180); // X, Y, Heading (degrees)
chassis.moveToPose(-48, -48 + 8, 60, 2500, {.forwards = false, .chasePower = 8});
// chassis.moveToPose(-48 - 5, -48 + 8, 70, 2500, {.forwards = false, .chasePower = 8});
// TODO: Ishika, test line 192 (directly above) to see if it gets the bot closer to the match load position than line 191

controller.print(1, 0, "Skills Complete");
break;
}
Expand Down
17 changes: 9 additions & 8 deletions src/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ pros::Controller controller(pros::E_CONTROLLER_MASTER);

// --- Left Drivetrain Motors
// Initializes the back left motor to port 8, reversed, with a blue gearset
pros::Motor BLMotor(-8, pros::E_MOTOR_GEAR_BLUE);
pros::Motor BLMotor(-1, pros::E_MOTOR_GEAR_BLUE);
// Initializes the middle left motor to port 9, reversed, with a blue gearset
pros::Motor MLMotor(-9, pros::E_MOTOR_GEAR_BLUE);
pros::Motor MLMotor(-11, pros::E_MOTOR_GEAR_BLUE);
// Initializes the front left motor to port 3, reversed, with a blue gearset
pros::Motor FLMotor(-3, pros::E_MOTOR_GEAR_BLUE);
pros::Motor FLMotor(-2, pros::E_MOTOR_GEAR_BLUE);

// --- Right Drivetrain Motors
// Initializes the back right motor to port 18 with a blue gearset
pros::Motor BRMotor(18, pros::E_MOTOR_GEAR_BLUE);
pros::Motor BRMotor(10, pros::E_MOTOR_GEAR_BLUE);
// Initializes the middle right motor to port 19 with a blue gearset
pros::Motor MRMotor(19, pros::E_MOTOR_GEAR_BLUE);
pros::Motor MRMotor(9, pros::E_MOTOR_GEAR_BLUE);
// Initializes the front right motor to port 20 with a blue gearset
pros::Motor FRMotor(20, pros::E_MOTOR_GEAR_BLUE);

Expand All @@ -28,15 +28,15 @@ pros::Motor_Group LMotors({BLMotor, MLMotor, FLMotor});
pros::Motor_Group RMotors({BRMotor, MRMotor, FRMotor});

// Initializes the kicker motor to port 12, reversed, with a red (torque) gearset
pros::Motor KickerMotor(-12, pros::E_MOTOR_GEAR_RED, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor KickerMotor(-18, pros::E_MOTOR_GEAR_RED, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor IntakeMotor(7, pros::E_MOTOR_GEAR_BLUE);

// Initializes DigitalOut objects to control the pneumatic wings.
pros::ADIDigitalOut HorizontalWingPistons('b');
pros::ADIDigitalOut VerticalWingPistons('a');

// Inertial Sensor
pros::IMU Inertial(4);
pros::IMU Inertial(8);

// Initializes the Optical Sensor to port 6
pros::Optical Optical(6);
Expand Down Expand Up @@ -69,8 +69,9 @@ void ControllerDisplay() {
5: Full Autonomous Win Point
6: No Auton
7: Programming Skills
8: Makhi Programming Skills
*/
unsigned short int autonSelect = 3;
unsigned short int autonSelect = 8;

/*
Integer variable to represent the current game phase
Expand Down
2 changes: 0 additions & 2 deletions src/opcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ float GetCurveOutput(int input) {
void opcontrol()
{
//autonomous();
// /*
ControllerDisplay();
// Integer variables to store the current position of the left (Axis 3) and right Y axis (Axis 2) joysticks
short int leftAxis;
Expand Down Expand Up @@ -135,5 +134,4 @@ void opcontrol()
// Creates a 20 millisecond delay between each loop of the driver control code to prevent the starving of PROS kernel resources
pros::delay(20);
}
// */
}

0 comments on commit f2b3788

Please sign in to comment.