Skip to content

Commit

Permalink
Fixed translator.
Browse files Browse the repository at this point in the history
  • Loading branch information
XQuestCode committed Jan 24, 2024
1 parent a4bf107 commit 7b675f4
Show file tree
Hide file tree
Showing 16 changed files with 1,669 additions and 234 deletions.
2 changes: 1 addition & 1 deletion coresdk/src/backend/gpio_driver.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***********************************************
* XQuestCode || Aditya Parmar
* 🚀 © 2024 Aditya Parmar. All Rights Reserved.
* © 2024 Aditya Parmar. All Rights Reserved.
* This file is part of the SplashKit Core Library.
* Use https://abyz.me.uk/rpi/pigpio/pdif2.html for reference
***********************************************/
Expand Down
4 changes: 2 additions & 2 deletions coresdk/src/backend/gpio_driver.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***********************************************
* XQuestCode || Aditya Parmar
* 🚀 © 2024 Aditya Parmar. All Rights Reserved.
* © 2024 Aditya Parmar. All Rights Reserved.
* This file is part of the SplashKit Core Library.
* Use https://abyz.me.uk/rpi/pigpio/pdif2.html for reference
***********************************************/
Expand All @@ -21,4 +21,4 @@ namespace splashkit_lib
void sk_set_pwm_dutycycle(int pin, int dutycycle);
void sk_gpio_cleanup();
}
#endif // SPLASHKIT_sk_gpio_H
#endif /* defined(gpio_driver) */
14 changes: 5 additions & 9 deletions coresdk/src/coresdk/raspi_gpio.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
// raspi_gpio.c
/***********************************************
* XQuestCode || Aditya Parmar
* 🚀 © 2024 Aditya Parmar. All Rights Reserved.
* This file is part of the SplashKit Core Library.
* Use https://abyz.me.uk/rpi/pigpio/pdif2.html for reference
***********************************************/

// raspi_gpio.cpp
// splashkit
// Created by Aditya Parmar on 20/01/2024.
// Copyright © 2024 XQuestCode. All rights reserved.
#include "raspi_gpio.h"
#include "gpio_driver.h"
#include <iostream>
using namespace std;
// Each index points to PIN_1, PIN_2, PIN_3, etc.

namespace splashkit_lib
{
// Each index points to PIN_1, PIN_2, PIN_3, etc.
int BCMpinData[] = {
-1, -1, 2, -1, 3, -2, 4, 14, -2, 15, 17, 18, 27, -2, 22, 23, -1, 24, 10, -2, 9, 25, 11, 8, -2, 7, 0, 1, 5, -2, -6, 12, 13, -2, 19, 16, 26, 20, -2, 21};

Expand Down
49 changes: 33 additions & 16 deletions coresdk/src/coresdk/raspi_gpio.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
/**
* @header raspberry
* @author Aditya Parmar
* @brief Splashkit allows you to read and write to the GPIO pins on the Raspberry Pi.
*
* @attribute group raspberry
* @header raspi_gpio
* @brief Splashkit allows you to read and write to the GPIO pins on the Raspberry Pi.
* @author Aditya Parmar
* @attribute group raspberry
* @attribute static raspberry
*/
#ifndef raspi_gpio_h
#define raspi_gpio_h

#ifndef raspi_gpio_hpp
#define raspi_gpio_hpp

#include <stdint.h> // Include the appropriate header file for stdint.h
#include <stdint.h>
#include "gpio_driver.h"
#include "types.h"

namespace splashkit_lib
{
/**
* @brief Initializes the GPIO library.
*
* This function initializes the GPIO library for use. It should be called before any other GPIO functions.
*/
void raspi_init();

/**
* @brief Sets the mode of the specified pin.
*
* This function sets the mode of the specified pin to the specified mode.
*
* @param pin The pin to set the mode for.
* @param mode The mode to set for the pin.
*/
Expand All @@ -32,6 +35,8 @@ namespace splashkit_lib
/**
* @brief Gets the mode of the specified pin.
*
* This function retrieves the mode of the specified pin.
*
* @param pin The pin to get the mode for.
* @returns The mode of the pin.
*/
Expand All @@ -40,6 +45,8 @@ namespace splashkit_lib
/**
* @brief Writes a value to the specified pin.
*
* This function writes the specified value to the specified pin.
*
* @param pin The pin to write the value to.
* @param value The value to write to the pin.
*/
Expand All @@ -48,48 +55,58 @@ namespace splashkit_lib
/**
* @brief Sets the pull up/down mode for the specified pin.
*
* This function sets the pull-up/down mode for the specified pin.
*
* @param pin The pin to set the pull up/down mode for.
* @param pud The pull up/down mode to set for the pin.
*/
void raspi_set_pull_up_down(pins pin, pull_up_down pud);

/**
* Sets the PWM range for the specified pin.
* @brief Sets the PWM range for the specified pin.
*
* This function sets the PWM range for the specified pin.
*
* @param pin The pin to set the PWM range for.
* @param range The PWM range to set for the pin.
*/
void raspi_set_pwm_range(pins pin, int range);

/**
* Sets the PWM frequency for the specified pin.
* @brief Sets the PWM frequency for the specified pin.
*
* This function sets the PWM frequency for the specified pin.
*
* @param pin The pin to set the PWM frequency for.
* @param frequency The PWM frequency to set for the pin.
*/
void raspi_set_pwm_frequency(pins pin, int frequency);

/**
* Sets the PWM duty cycle for the specified pin.
* @brief Sets the PWM duty cycle for the specified pin.
*
* This function sets the PWM duty cycle for the specified pin.
*
* @param pin The pin to set the PWM duty cycle for.
* @param dutycycle The PWM duty cycle to set for the pin.
*/
void raspi_set_pwm_dutycycle(pins pin, int dutycycle);

/**
* Reads the value from the specified pin.
* @brief Reads the value from the specified pin.
*
* This function reads the value from the specified pin.
*
* @param pin The pin to read the value from.
* @returns The value read from the pin.
*/
pin_values raspi_read(pins pin);



/**
* Cleans up and releases any resources used by the GPIO library ( sets all pin modes to INPUT and values to LOW ). This should be called when you are finished using the GPIO library.
* @brief Cleans up and releases any resources used by the GPIO library.
*
* This function should be called when you are finished using the GPIO library. It sets all pin modes to INPUT and values to LOW.
*/
void raspi_cleanup();
}
#endif // RASPI_GPIO_H
#endif /* raspi_gpio_hpp */
106 changes: 53 additions & 53 deletions coresdk/src/coresdk/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,46 +319,46 @@ namespace splashkit_lib
/**
* Raspberry Pi GPIO Board Pin Descriptions:
*
* @constant PIN_1 - 3.3V Power Supply
* @constant PIN_2 - 5V Power Supply
* @constant PIN_3 - GPIO2 / SDA (I2C)
* @constant PIN_4 - 5V Power Supply
* @constant PIN_5 - GPIO3 / SCL (I2C)
* @constant PIN_6 - Ground
* @constant PIN_7 - GPIO4
* @constant PIN_8 - GPIO14 / TXD (UART)
* @constant PIN_9 - Ground
* @constant PIN_10 - GPIO15 / RXD (UART)
* @constant PIN_11 - GPIO17
* @constant PIN_12 - GPIO18 / PCM_CLK
* @constant PIN_13 - GPIO27
* @constant PIN_14 - Ground
* @constant PIN_15 - GPIO22
* @constant PIN_16 - GPIO23
* @constant PIN_17 - 3.3V Power Supply
* @constant PIN_18 - GPIO24
* @constant PIN_19 - GPIO10 / MOSI (SPI)
* @constant PIN_20 - Ground
* @constant PIN_21 - GPIO9 / MISO (SPI)
* @constant PIN_22 - GPIO25
* @constant PIN_23 - GPIO11 / SCLK (SPI)
* @constant PIN_24 - GPIO8 / CE0 (SPI)
* @constant PIN_25 - Ground
* @constant PIN_26 - GPIO7 / CE1 (SPI)
* @constant PIN_27 - ID_SD (I2C ID EEPROM)
* @constant PIN_28 - ID_SC (I2C ID EEPROM)
* @constant PIN_29 - GPIO5
* @constant PIN_30 - Ground
* @constant PIN_31 - GPIO6
* @constant PIN_32 - GPIO12
* @constant PIN_33 - GPIO13
* @constant PIN_34 - Ground
* @constant PIN_35 - GPIO19 / MISO (PCM)
* @constant PIN_36 - GPIO16 / CE0 (PCM)
* @constant PIN_37 - GPIO26
* @constant PIN_38 - GPIO20 / MOSI (PCM)
* @constant PIN_39 - Ground
* @constant PIN_40 - GPIO21 / SCLK (PCM)
* @constant PIN_1 3.3V Power Supply
* @constant PIN_2 5V Power Supply
* @constant PIN_3 GPIO2 / SDA (I2C)
* @constant PIN_4 5V Power Supply
* @constant PIN_5 GPIO3 / SCL (I2C)
* @constant PIN_6 Ground
* @constant PIN_7 GPIO4
* @constant PIN_8 GPIO14 / TXD (UART)
* @constant PIN_9 Ground
* @constant PIN_10 GPIO15 / RXD (UART)
* @constant PIN_11 GPIO17
* @constant PIN_12 GPIO18 / PCM_CLK
* @constant PIN_13 GPIO27
* @constant PIN_14 Ground
* @constant PIN_15 GPIO22
* @constant PIN_16 GPIO23
* @constant PIN_17 3.3V Power Supply
* @constant PIN_18 GPIO24
* @constant PIN_19 GPIO10 / MOSI (SPI)
* @constant PIN_20 Ground
* @constant PIN_21 GPIO9 / MISO (SPI)
* @constant PIN_22 GPIO25
* @constant PIN_23 GPIO11 / SCLK (SPI)
* @constant PIN_24 GPIO8 / CE0 (SPI)
* @constant PIN_25 Ground
* @constant PIN_26 GPIO7 / CE1 (SPI)
* @constant PIN_27 ID_SD (I2C ID EEPROM)
* @constant PIN_28 ID_SC (I2C ID EEPROM)
* @constant PIN_29 GPIO5
* @constant PIN_30 Ground
* @constant PIN_31 GPIO6
* @constant PIN_32 GPIO12
* @constant PIN_33 GPIO13
* @constant PIN_34 Ground
* @constant PIN_35 GPIO19 / MISO (PCM)
* @constant PIN_36 GPIO16 / CE0 (PCM)
* @constant PIN_37 GPIO26
* @constant PIN_38 GPIO20 / MOSI (PCM)
* @constant PIN_39 Ground
* @constant PIN_40 GPIO21 / SCLK (PCM)
*/
enum pins
{
Expand Down Expand Up @@ -408,14 +408,14 @@ enum pins
/**
* GPIO Pin Modes:
*
* @constant GPIO_INPUT - Input mode.
* @constant GPIO_OUTPUT - Output mode.
* @constant GPIO_ALT0 - Alternate function mode 0.
* @constant GPIO_ALT1 - Alternate function mode 1.
* @constant GPIO_ALT2 - Alternate function mode 2.
* @constant GPIO_ALT3 - Alternate function mode 3.
* @constant GPIO_ALT4 - Alternate function mode 4.
* @constant GPIO_ALT5 - Alternate function mode 5.
* @constant GPIO_INPUT Input mode.
* @constant GPIO_OUTPUT Output mode.
* @constant GPIO_ALT0 Alternate function mode 0.
* @constant GPIO_ALT1 Alternate function mode 1.
* @constant GPIO_ALT2 Alternate function mode 2.
* @constant GPIO_ALT3 Alternate function mode 3.
* @constant GPIO_ALT4 Alternate function mode 4.
* @constant GPIO_ALT5 Alternate function mode 5.
*/
enum pin_modes
{
Expand All @@ -432,8 +432,8 @@ enum pin_modes
/**
* GPIO Pin Values:
*
* @constant GPIO_LOW - Logic low (0).
* @constant GPIO_HIGH - Logic high (1).
* @constant GPIO_LOW Logic low (0).
* @constant GPIO_HIGH Logic high (1).
*/
enum pin_values
{
Expand All @@ -443,9 +443,9 @@ enum pin_values
/**
* GPIO Pull-up/Pull-down Configurations:
*
* @constant PUD_OFF - No pull-up or pull-down resistor.
* @constant PUD_DOWN - Enable pull-down resistor.
* @constant PUD_UP - Enable pull-up resistor.
* @constant PUD_OFF No pull-up or pull-down resistor.
* @constant PUD_DOWN Enable pull-down resistor.
* @constant PUD_UP Enable pull-up resistor.
*/
enum pull_up_down
{
Expand Down
1 change: 1 addition & 0 deletions generated/clib/lib_type_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "point_geometry.h"
#include "quad_geometry.h"
#include "random.h"
#include "raspi_gpio.h"
#include "rectangle_drawing.h"
#include "rectangle_geometry.h"
#include "resources.h"
Expand Down
46 changes: 46 additions & 0 deletions generated/clib/sk_clib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,52 @@ int __sklib__rnd__int(int ubound) {
int __skreturn = rnd(__skparam__ubound);
return __sklib__to_int(__skreturn);
}
void __sklib__raspi_cleanup() {
raspi_cleanup();
}
int __sklib__raspi_get_mode__pins(int pin) {
pins __skparam__pin = __sklib__to_pins(pin);
pin_modes __skreturn = raspi_get_mode(__skparam__pin);
return __sklib__to_int(__skreturn);
}
void __sklib__raspi_init() {
raspi_init();
}
int __sklib__raspi_read__pins(int pin) {
pins __skparam__pin = __sklib__to_pins(pin);
pin_values __skreturn = raspi_read(__skparam__pin);
return __sklib__to_int(__skreturn);
}
void __sklib__raspi_set_mode__pins__pin_modes(int pin, int mode) {
pins __skparam__pin = __sklib__to_pins(pin);
pin_modes __skparam__mode = __sklib__to_pin_modes(mode);
raspi_set_mode(__skparam__pin, __skparam__mode);
}
void __sklib__raspi_set_pull_up_down__pins__pull_up_down(int pin, int pud) {
pins __skparam__pin = __sklib__to_pins(pin);
pull_up_down __skparam__pud = __sklib__to_pull_up_down(pud);
raspi_set_pull_up_down(__skparam__pin, __skparam__pud);
}
void __sklib__raspi_set_pwm_dutycycle__pins__int(int pin, int dutycycle) {
pins __skparam__pin = __sklib__to_pins(pin);
int __skparam__dutycycle = __sklib__to_int(dutycycle);
raspi_set_pwm_dutycycle(__skparam__pin, __skparam__dutycycle);
}
void __sklib__raspi_set_pwm_frequency__pins__int(int pin, int frequency) {
pins __skparam__pin = __sklib__to_pins(pin);
int __skparam__frequency = __sklib__to_int(frequency);
raspi_set_pwm_frequency(__skparam__pin, __skparam__frequency);
}
void __sklib__raspi_set_pwm_range__pins__int(int pin, int range) {
pins __skparam__pin = __sklib__to_pins(pin);
int __skparam__range = __sklib__to_int(range);
raspi_set_pwm_range(__skparam__pin, __skparam__range);
}
void __sklib__raspi_write__pins__pin_values(int pin, int value) {
pins __skparam__pin = __sklib__to_pins(pin);
pin_values __skparam__value = __sklib__to_pin_values(value);
raspi_write(__skparam__pin, __skparam__value);
}
void __sklib__draw_quad__color__quad_ref(__sklib_color clr, const __sklib_quad q) {
color __skparam__clr = __sklib__to_color(clr);
quad __skparam__q = __sklib__to_quad(q);
Expand Down
10 changes: 10 additions & 0 deletions generated/clib/sk_clib.h
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,16 @@ __sklib_vector_triangle __sklib__triangles_from__quad_ref(const __sklib_quad q);
int __sklib__rnd__int__int(int min, int max);
float __sklib__rnd();
int __sklib__rnd__int(int ubound);
void __sklib__raspi_cleanup();
int __sklib__raspi_get_mode__pins(int pin);
void __sklib__raspi_init();
int __sklib__raspi_read__pins(int pin);
void __sklib__raspi_set_mode__pins__pin_modes(int pin, int mode);
void __sklib__raspi_set_pull_up_down__pins__pull_up_down(int pin, int pud);
void __sklib__raspi_set_pwm_dutycycle__pins__int(int pin, int dutycycle);
void __sklib__raspi_set_pwm_frequency__pins__int(int pin, int frequency);
void __sklib__raspi_set_pwm_range__pins__int(int pin, int range);
void __sklib__raspi_write__pins__pin_values(int pin, int value);
void __sklib__draw_quad__color__quad_ref(__sklib_color clr, const __sklib_quad q);
void __sklib__draw_quad__color__quad_ref__drawing_options_ref(__sklib_color clr, const __sklib_quad q, const __sklib_drawing_options opts);
void __sklib__draw_quad_on_bitmap__bitmap__color__quad_ref(__sklib_bitmap destination, __sklib_color clr, const __sklib_quad q);
Expand Down
Loading

0 comments on commit 7b675f4

Please sign in to comment.