ソースを参照

Working test thing

Emil 3 年 前
コミット
a257428b9d
5 ファイル変更105 行追加0 行削除
  1. 3 0
      .gitignore
  2. 33 0
      CMakeLists.txt
  3. 1 0
      monitor.sh
  4. 16 0
      platformio.ini
  5. 52 0
      src/main.cpp

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+.pio
+CMakeListsPrivate.txt
+cmake-build-*/ 

+ 33 - 0
CMakeLists.txt

@@ -0,0 +1,33 @@
+# !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE
+# https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
+#
+# If you need to override existing CMake configuration or add extra,
+# please create `CMakeListsUser.txt` in the root of project.
+# The `CMakeListsUser.txt` will not be overwritten by PlatformIO.
+
+cmake_minimum_required(VERSION 3.13)
+set(CMAKE_SYSTEM_NAME Generic)
+set(CMAKE_C_COMPILER_WORKS 1)
+set(CMAKE_CXX_COMPILER_WORKS 1)
+
+project("untitled" C CXX)
+
+include(CMakeListsPrivate.txt)
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsUser.txt)
+include(CMakeListsUser.txt)
+endif()
+
+add_custom_target(
+    Production ALL
+    COMMAND platformio -c clion run "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+add_custom_target(
+    Debug ALL
+    COMMAND platformio -c clion debug "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>"
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+add_executable(Z_DUMMY_TARGET ${SRC_LIST})

+ 1 - 0
monitor.sh

@@ -0,0 +1 @@
+pio device monitor -b 115200

+ 16 - 0
platformio.ini

@@ -0,0 +1,16 @@
+; 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:esp32doit-devkit-v1]
+platform = espressif32
+board = esp32doit-devkit-v1
+framework = arduino
+lib_deps = 
+	adafruit/Adafruit NeoPixel@^1.10.4

+ 52 - 0
src/main.cpp

@@ -0,0 +1,52 @@
+#include <Arduino.h>
+#include "../.pio/libdeps/esp32doit-devkit-v1/Adafruit NeoPixel/Adafruit_NeoPixel.h"
+
+#define LED_PIN    4
+#define NUM_LEDS 10
+
+Adafruit_NeoPixel leds(NUM_LEDS, LED_PIN, NEO_WRGB + NEO_KHZ800);
+
+
+void setup() {
+    // write your initialization code here
+    Serial.begin(115000);
+    delay(1000);
+    leds.begin();
+    leds.clear();
+}
+
+void loop() {
+
+    leds.clear();
+    delay(1000);
+    for (int i = 0; i < 360; i++) {
+        for (int light = 0; light < NUM_LEDS; light++) {
+            leds.setPixelColor(light, leds.ColorHSV(((light*360/10)+i)*360, 255, 255));
+        }
+        leds.show();
+        delay(200);
+    }
+    leds.clear();
+    delay(1000);
+
+    for (int i = 0; i < NUM_LEDS; i++) {
+        leds.setPixelColor(i, 0, 255, 0, 0);
+        leds.show();
+        delay(1000);
+    }
+
+    leds.clear();
+    leds.show();
+    delay(1000);
+
+    for (int i = 0; i < 10; i++) {
+        leds.clear();
+        for (int light = 0; light < NUM_LEDS; light++) {
+            if (random(2) == 1) {
+                leds.setPixelColor(light, rand());
+            }
+        }
+        leds.show();
+        delay(1000);
+    }
+}