add platformio project instead of arduino ide
This commit is contained in:
parent
19c923ce69
commit
9a5d6523be
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@
|
||||
build
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/settings.json
|
||||
.idea/
|
||||
**/.idea/
|
||||
1
nano/nano_c64/.gitignore
vendored
Normal file
1
nano/nano_c64/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.pio
|
||||
37
nano/nano_c64/include/README
Normal file
37
nano/nano_c64/include/README
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the convention is to give header files names that end with `.h'.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
46
nano/nano_c64/lib/README
Normal file
46
nano/nano_c64/lib/README
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into the executable file.
|
||||
|
||||
The source code of each library should be placed in a separate directory
|
||||
("lib/your_library_name/[Code]").
|
||||
|
||||
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Example contents of `src/main.c` using Foo and Bar:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
The PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries by scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
14
nano/nano_c64/platformio.ini
Normal file
14
nano/nano_c64/platformio.ini
Normal file
@ -0,0 +1,14 @@
|
||||
; 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:nanoatmega328]
|
||||
platform = atmelavr
|
||||
board = nanoatmega328new
|
||||
framework = arduino
|
||||
156
nano/nano_c64/src/main.cpp
Normal file
156
nano/nano_c64/src/main.cpp
Normal file
@ -0,0 +1,156 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#define DP_0 2
|
||||
#define DP_1 3
|
||||
#define DP_2 4
|
||||
#define DP_3 5
|
||||
#define AR 6
|
||||
#define CR 7
|
||||
|
||||
#define STANDBY 0
|
||||
#define READ 1
|
||||
#define WRITE 2
|
||||
|
||||
char count = 0;
|
||||
char delayAmount = 100;
|
||||
char textToSent[] = "Test!";
|
||||
|
||||
char mode;
|
||||
|
||||
char getScreenCode(char c) {
|
||||
if ((c >= 32 && c <= 63) || (c >= 65 && c <= 90) || c == 0) {
|
||||
return c;
|
||||
}
|
||||
if (c == 64) {
|
||||
return 0;
|
||||
}
|
||||
if (c == 91 || c == 93) {
|
||||
return static_cast<char>(c - 64);
|
||||
}
|
||||
if (c == 95) {
|
||||
return 111;
|
||||
}
|
||||
if (c >= 97 && c <= 122) {
|
||||
return static_cast<char>(c - 96);
|
||||
}
|
||||
if (c == 124) {
|
||||
return 93;
|
||||
}
|
||||
return 63;
|
||||
}
|
||||
|
||||
void initMode(const char modeToSet) {
|
||||
|
||||
switch (modeToSet) {
|
||||
case WRITE:
|
||||
pinMode(DP_0, OUTPUT);
|
||||
pinMode(DP_1, OUTPUT);
|
||||
pinMode(DP_2, OUTPUT);
|
||||
pinMode(DP_3, OUTPUT);
|
||||
break;
|
||||
case STANDBY:
|
||||
default:
|
||||
pinMode(DP_0, INPUT);
|
||||
pinMode(DP_1, INPUT);
|
||||
pinMode(DP_2, INPUT);
|
||||
pinMode(DP_3, INPUT);
|
||||
}
|
||||
|
||||
pinMode(AR, OUTPUT);
|
||||
pinMode(CR, INPUT);
|
||||
|
||||
digitalWrite(DP_0, LOW);
|
||||
digitalWrite(DP_1, LOW);
|
||||
digitalWrite(DP_2, LOW);
|
||||
digitalWrite(DP_3, LOW);
|
||||
digitalWrite(AR, LOW);
|
||||
digitalWrite(CR, LOW);
|
||||
|
||||
}
|
||||
|
||||
void setup() {
|
||||
delay(2000);
|
||||
mode = STANDBY;
|
||||
initMode(mode);
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
}
|
||||
|
||||
void send4Bit(char c) {
|
||||
|
||||
for (char i = 3; i >= 0; i--) {
|
||||
char d = c >> i & 1;
|
||||
Serial.print(d, DEC);
|
||||
}
|
||||
|
||||
for (char i = 0; i < 4; i++) {
|
||||
char d = c >> i & 1;
|
||||
digitalWrite(i+2, d);
|
||||
}
|
||||
Serial.print(" ");
|
||||
digitalWrite(AR, HIGH);
|
||||
|
||||
while (digitalRead(CR) == LOW) {}
|
||||
|
||||
while (digitalRead(CR) == HIGH) {}
|
||||
digitalWrite(AR, LOW);
|
||||
|
||||
//delay(500);
|
||||
}
|
||||
|
||||
void sendByte(char a, char byte) {
|
||||
char upper = byte >> 4;
|
||||
char lower = byte & 0b00001111;
|
||||
|
||||
|
||||
Serial.print(a);
|
||||
Serial.print(" ");
|
||||
Serial.print(a, DEC);
|
||||
Serial.print(" ");
|
||||
Serial.print(byte, DEC);
|
||||
Serial.print(" ");
|
||||
send4Bit(upper);
|
||||
send4Bit(lower);
|
||||
}
|
||||
|
||||
void startWrite() {
|
||||
Serial.print("start\n");
|
||||
mode = WRITE;
|
||||
initMode(mode);
|
||||
digitalWrite(AR, LOW);
|
||||
|
||||
int i = 0;
|
||||
char c, sc;
|
||||
do {
|
||||
c = textToSent[i];
|
||||
sc = getScreenCode(c);
|
||||
i++;
|
||||
sendByte(c, sc);
|
||||
//Serial.print(c, DEC);
|
||||
} while (c != 0);
|
||||
|
||||
Serial.print("\n");
|
||||
|
||||
for (char i = 2; i < 8; i++) {
|
||||
digitalWrite(i, LOW);
|
||||
}
|
||||
|
||||
mode = STANDBY;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (mode == WRITE) {
|
||||
|
||||
} else if (mode == READ) {
|
||||
|
||||
} else {
|
||||
startWrite();
|
||||
}
|
||||
|
||||
Serial.print("\nAAAAAAAA\n");
|
||||
|
||||
delay(20000);
|
||||
|
||||
}
|
||||
11
nano/nano_c64/test/README
Normal file
11
nano/nano_c64/test/README
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||
Loading…
x
Reference in New Issue
Block a user