Skip to content

Commit 189030c

Browse files
committed
Initial commit
0 parents  commit 189030c

File tree

9 files changed

+993
-0
lines changed

9 files changed

+993
-0
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# NAZIV PROIZVODA Arduino library
2+
3+
[![Compile Sketches](http://github-actions.40ants.com/e-radionicacom/Soldered-Generic-Arduino-Library/matrix.svg?branch=dev&only=Compile%20Sketches)](https://github.com/e-radionicacom/Soldered-Generic-Arduino-Library/actions/workflows/compile_test.yml)
4+
[![Make docs and publish to GitHub Pages](https://github.com/e-radionicacom/Soldered-Generic-Arduino-Library/actions/workflows/make_docs.yml/badge.svg?branch=dev)](https://github.com/e-radionicacom/Soldered-Generic-Arduino-Library/actions/workflows/make_docs.yml)
5+
6+
| ![Product name](https://upload.wikimedia.org/wikipedia/commons/8/8f/Example_image.svg) |
7+
| :---------------------------------------------------------------------------------------------: |
8+
| [NAZIV PROIZVODA](https://www.solde.red/SKU) |
9+
10+
OPIS PROIZVODA + LINK NA [easyC ecosystem](https://www.soldered.com/easyC).
11+
12+
### Repository Contents
13+
- **/src** - source files for the library (.h & .cpp)
14+
- **/examples** - examples for using the library
15+
- ***other*** - *keywords* file highlights function words in your IDE, *library.properties* enables implementation with Arduino Library Manager.
16+
17+
### Hardware design
18+
You can find hardware design for this board in NAZIV PROIZVODA hardware repository
19+
20+
### Documentation
21+
22+
Access Arduino library documentation [here](https://e-radionicacom.github.io/Soldered-Generic-Arduino-Library/).
23+
24+
- Tutorial for using the NAZIV PROIZVODA board
25+
- Installing an Arduino library
26+
27+
### About Soldered
28+
![Soldered logo](https://raw.githubusercontent.com/e-radionicacom/Soldered-Generic-Arduino-Library/dev/extras/Logo%20horizontal-2.svg)
29+
30+
At Soldered, we design and manufacture a wide selection of electronic products to help you turn your ideas into acts and bring you one step closer to your final project. Our products are intented for makers and crafted in-house by our experienced team in Osijek, Croatia. We believe that sharing is a crucial element for improvement and innovation, and we work hard to stay connected with all our makers regardless of their skill or experience level. Therefore, all our products are open-source. Finally, we always have your back. If you face any problem concerning either your shopping experience or your electronics project, our team will help you deal with it, offering efficient customer service and cost-free technical support anytime. Some of those might be useful for you:
31+
32+
- [Web Store](https://www.soldered.com)
33+
- [Educational content](https://learn.soldered.com)
34+
- [Community & technical support](https://community.soldered.com)
35+
- [Custom PCBs](https://pcb.soldered.com)
36+
37+
38+
### Original source
39+
40+
This library is possible thanks to original [arduino-mcp23017](https://github.com/blemasle/arduino-mcp23017) library. Thank you, blemasle.
41+
42+
43+
### Open-source license
44+
Soldered invests vast amounts of time into hardware & software for these products, which are all open-source. Please support future development by buying one of our products.
45+
46+
Check license details in the LICENSE file. Long story short, use these open-source files for any purpose you want to, as long as you apply the same open-source licence to it and disclose the original source. No warranty - all designs in this repository are distributed in the hope that they will be useful, but without any warranty. They are provided "AS IS", therefore without warranty of any kind, either expressed or implied. The entire quality and performance of what you do with the contents of this repository are your responsibility. In no event, Soldered (TAVU) will be liable for your damages, losses, including any general, special, incidental or consequential damage arising out of the use or inability to use the contents of this repository.
47+
48+
Thank you from your fellow makers at Soldered.
49+

examples/Template/Template.ino

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file Template.ino
5+
* @brief Example template for easyC sensors
6+
*
7+
*
8+
*
9+
* @authors @ soldered.com
10+
***************************************************/
11+
12+
#include "Generic-easyC-SOLDERED.h"
13+
14+
void setup()
15+
{
16+
}
17+
18+
void loop()
19+
{
20+
}

keywords.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
##################################################
2+
# Syntax Coloring Map For Obstacle-Sensor-SOLDERED
3+
##################################################
4+
5+
##################################################
6+
# Datatypes (KEYWORD1)
7+
##################################################
8+
9+
##################################################
10+
# Methods and Functions (KEYWORD2)
11+
##################################################
12+
13+
begin KEYWORD2
14+
15+
##################################################
16+
# Constants (LITERAL1)
17+
##################################################

library.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=easyC_template
2+
version=0.1.0
3+
author=Soldered
4+
maintainer=Soldered <[email protected]>
5+
sentence=Only a template used to create other libraries
6+
paragraph=Template, should not be used like this
7+
category=Sensor
8+
url=www.soldered.com
9+
architectures=*
10+
includes=Generic-easyC-SOLDERED.h

src/Generic-easyC-SOLDERED.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file Generic-easyC-SOLDERED.cpp
5+
* @brief Example functions to overload in base class.
6+
*
7+
*
8+
* @copyright GNU General Public License v3.0
9+
* @authors @ soldered.com
10+
***************************************************/
11+
12+
13+
#include "Generic-easyC-SOLDERED.h"
14+
15+
/**
16+
* @brief Sensor specific native constructor.
17+
*
18+
* @param int _pin Example parameter.
19+
*/
20+
Sensor::Sensor(int _pin)
21+
{
22+
pin = _pin;
23+
native = 1;
24+
}
25+
26+
/**
27+
* @brief Overloaded function for virtual in base class to initialize sensor specific.
28+
*/
29+
void Sensor::initializeNative()
30+
{
31+
pinMode(pin, INPUT);
32+
}

src/Generic-easyC-SOLDERED.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file Generic-easyC-SOLDERED.h
5+
* @brief Header file for sensor specific code.
6+
*
7+
*
8+
* @copyright GNU General Public License v3.0
9+
* @authors @ soldered.com
10+
***************************************************/
11+
12+
#ifndef __SENSOR__
13+
#define __SENSOR__
14+
15+
#include "Arduino.h"
16+
#include "libs/Generic-easyC/easyC.h"
17+
18+
class Sensor : public EasyC
19+
{
20+
public:
21+
Sensor(int _pin);
22+
23+
protected:
24+
void initializeNative();
25+
26+
private:
27+
int pin;
28+
};
29+
30+
#endif

src/libs/Generic-easyC/easyC.cpp

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file easyC.cpp
5+
* @brief Basic funtions for easyC
6+
*
7+
*
8+
* @copyright GNU General Public License v3.0
9+
* @authors @ soldered.com
10+
***************************************************/
11+
12+
#include "easyC.h"
13+
14+
/**
15+
* @brief Main constructor for easyC version
16+
*
17+
*/
18+
EasyC::EasyC()
19+
{
20+
native = 0;
21+
}
22+
23+
/**
24+
* @brief Initializes sensors on native or easyC on default address
25+
*/
26+
void EasyC::begin()
27+
{
28+
if (native)
29+
initializeNative();
30+
else
31+
begin(defaultAddress);
32+
33+
beginDone = 1;
34+
}
35+
36+
/**
37+
* @brief Initializes sensors on supplied i2c address
38+
*
39+
* @param uint8_t _address Custom easyC sensor address
40+
*/
41+
void EasyC::begin(uint8_t _address)
42+
{
43+
address = _address;
44+
45+
Wire.begin();
46+
47+
beginDone = 1;
48+
}
49+
50+
/**
51+
* @brief Private function to send over i2c and then read n bytes
52+
*
53+
* @param char regAddr Address of register to access data from
54+
* @param char a Array to put data in
55+
* @param size_t n Size of data to read
56+
*
57+
* @return int 0 if read successfuly, error code from endTransmission if not
58+
*/
59+
int EasyC::readRegister(char regAddr, char a[], size_t n)
60+
{
61+
if (sendAddress(regAddr))
62+
return err;
63+
64+
if (readData(a, n))
65+
return err;
66+
67+
return 0;
68+
}
69+
70+
/**
71+
* @brief Private function to send a single byte to sensor
72+
*
73+
* @param char regAddr Address of register to access later
74+
*
75+
* @return int Standard endTransmission error codes
76+
*/
77+
int EasyC::sendAddress(char regAddr)
78+
{
79+
Wire.beginTransmission(address);
80+
Wire.write(regAddr);
81+
82+
return err = Wire.endTransmission();
83+
}
84+
85+
/**
86+
* @brief Private function to read n bytes over i2c
87+
*
88+
* @param char a[] Array to read data to
89+
* @param int n Number of bytes to read
90+
*
91+
* @return int Error code, always 0
92+
*/
93+
int EasyC::readData(char a[], int n)
94+
{
95+
Wire.requestFrom(address, n);
96+
Wire.readBytes(a, n);
97+
98+
return 0;
99+
}
100+
101+
/**
102+
* @brief Private function to write n bytes over i2c
103+
*
104+
* @param char a[] Array to read data from
105+
* @param int n Number of bytes to read
106+
*
107+
* @return int Standard endTransmission error codes
108+
*/
109+
int EasyC::sendData(const uint8_t *a, int n)
110+
{
111+
Wire.beginTransmission(address);
112+
Wire.write(a, n);
113+
114+
return err = Wire.endTransmission();
115+
}

src/libs/Generic-easyC/easyC.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
**************************************************
3+
*
4+
* @file easyC.h
5+
* @brief Basic funtions for easyC libraries
6+
*
7+
*
8+
* @copyright GNU General Public License v3.0
9+
* @authors @ soldered.com
10+
***************************************************/
11+
12+
#ifndef __EASYC_LIBRARY__
13+
#define __EASYC_LIBRARY__
14+
15+
#include "Arduino.h"
16+
#include "Wire.h"
17+
18+
#define ANALOG_READ_REG 0
19+
#define DIGITAL_READ_REG 1
20+
21+
class EasyC
22+
{
23+
public:
24+
EasyC();
25+
26+
void begin();
27+
void begin(uint8_t _address);
28+
29+
protected:
30+
int native = 0;
31+
bool beginDone = 0;
32+
33+
virtual void initializeNative() = 0;
34+
35+
int err;
36+
37+
char address;
38+
const char defaultAddress = 0x30;
39+
40+
int sendAddress(char regAddr);
41+
int readData(char a[], int n);
42+
int sendData(const uint8_t *a, int n);
43+
int readRegister(char regAddr, char a[], size_t n);
44+
};
45+
46+
#endif

0 commit comments

Comments
 (0)