Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WString and Misc changes #8

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,17 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: '3.11'
cache: 'pip'
cache-dependency-path: .github/workflows/requirements.txt

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Install dependencies
run: pip install -r .github/workflows/requirements.txt

- name: Deploy Package to Registry
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
platformio~=6.1.15
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test

# Controls when the action will run.
on: [push, workflow_dispatch]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# The introduction just shows some useful informations.
intro:
# The type of runner that the job will run on.
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job.
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "The name of the branch is ${{ github.ref }} and the repository is ${{ github.repository }}."

test:
# The type of runner that the job will run on.
runs-on: ubuntu-latest
# Intro must run first
needs: intro
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: .github/workflows/requirements.txt

- name: Install dependencies
run: pip install -r .github/workflows/requirements.txt

- name: Perform static checks on native environment
run: platformio check --environment native --fail-on-defect=medium --fail-on-defect=high

- name: Run tests on native environment
run: platformio test --environment native -vvv
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

# Build artifacts
.pio
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ArduinoNative",
"version": "0.1.1",
"version": "0.2.0",
"description": "Arduino for the native environment. It doesn't support every interface, just some of them!",
"authors": [{
"name": "Andreas Merkle",
Expand Down
24 changes: 24 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:native]
platform = native @ ~1.2.1
build_flags =
-std=c++11
-DTARGET_NATIVE
-DUNIT_TEST
check_tool = clangtidy
check_severity = medium, high
check_src_filters =
src
check_flags =
clangtidy: --header-filter='' --checks=-*,clang-analyzer-*,performance-*,portability-*,readability-uppercase-literal-suffix,readability-redundant-control-flow --warnings-as-errors=-*,clang-analyzer-*,performance-*,portability-*,readability-uppercase-literal-suffix,readability-redundant-control-flow
check_skip_packages = yes
debug_test = test_WString
234 changes: 117 additions & 117 deletions src/Arduino.h
Original file line number Diff line number Diff line change
@@ -1,118 +1,118 @@
/* MIT License
*
* Copyright (c) 2023 - 2024 Andreas Merkle <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

/*******************************************************************************
DESCRIPTION
*******************************************************************************/
/**
* @brief Arduino native
* @author Andreas Merkle <[email protected]>
*
* @addtogroup Arduino
*
* @{
*/

#ifndef ARDUINO_H
#define ARDUINO_H

/******************************************************************************
* Compile Switches
*****************************************************************************/

#define _USE_MATH_DEFINES

/******************************************************************************
* Includes
*****************************************************************************/
#include <string.h>
#include <math.h>
#include "Serial.h"

/******************************************************************************
* Macros
*****************************************************************************/

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

#ifndef PSTR
#define PSTR
#endif

#ifndef PROGMEM
#define PROGMEM
#endif

#define PI M_PI

/******************************************************************************
* Types and Classes
*****************************************************************************/

/**
* This type defines the prototype to get the system tick counter in ms.
*/
typedef unsigned long (*GetSystemTick)();

/**
* This type defines the prototype to delay for a specific time in ms.
*/
typedef void (*SystemDelay)(unsigned long ms);

/******************************************************************************
* Functions
*****************************************************************************/

/** Arduino internal specific functionality.*/
namespace Arduino
{
/**
* Setup the Arduino library and call the application setup() function.
*/
void setup(GetSystemTick getSystemTickFunc, SystemDelay systemDelayFunc);

/**
* Loop shall be called periodically and handles Arduino library
* functionality and call the application loop() function.
*/
void loop();
}

/**
* Returns the number of milliseconds passed since the system start.
*
* @return The number of milliseconds.
*/
extern unsigned long millis();

/**
* Delays the program for the specified amount of milliseconds. In the mean time the
* simulation still steps to prevent an endless loop.
*
* @param[in] ms The amount of milliseconds that the program should be delayed by.
*/
extern void delay(unsigned long ms);

#endif /* ARDUINO_H */

/* MIT License
*
* Copyright (c) 2023 - 2024 Andreas Merkle <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*******************************************************************************
DESCRIPTION
*******************************************************************************/
/**
* @brief Arduino native
* @author Andreas Merkle <[email protected]>
*
* @addtogroup Arduino
*
* @{
*/
#ifndef ARDUINO_H
#define ARDUINO_H
/******************************************************************************
* Compile Switches
*****************************************************************************/
#define _USE_MATH_DEFINES
/******************************************************************************
* Includes
*****************************************************************************/
#include <string.h>
#include <math.h>
#include "Serial.h"
/******************************************************************************
* Macros
*****************************************************************************/
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#ifndef PSTR
#define PSTR
#endif
#ifndef PROGMEM
#define PROGMEM
#endif
#define PI M_PI
/******************************************************************************
* Types and Classes
*****************************************************************************/
/**
* This type defines the prototype to get the system tick counter in ms.
*/
typedef unsigned long (*GetSystemTick)();
/**
* This type defines the prototype to delay for a specific time in ms.
*/
typedef void (*SystemDelay)(unsigned long ms);
/******************************************************************************
* Functions
*****************************************************************************/
/** Arduino internal specific functionality.*/
namespace Arduino
{
/**
* Setup the Arduino library and call the application setup() function.
*/
void setup(GetSystemTick getSystemTickFunc, SystemDelay systemDelayFunc);
/**
* Loop shall be called periodically and handles Arduino library
* functionality and call the application loop() function.
*/
void loop();
}
/**
* Returns the number of milliseconds passed since the system start.
*
* @return The number of milliseconds.
*/
extern unsigned long millis();
/**
* Delays the program for the specified amount of milliseconds. In the mean time the
* simulation still steps to prevent an endless loop.
*
* @param[in] ms The amount of milliseconds that the program should be delayed by.
*/
extern void delay(unsigned long ms);
#endif /* ARDUINO_H */
/** @} */
Loading