diff --git a/.drone.yml b/.drone.yml
index 7a80404..829a96d 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -7,13 +7,30 @@ steps:
- apt-get -y update
- apt-get -y install libusb-1.0
- make
- - name: release
- image: plugins/gitea-release
- settings:
- api_key:
- from_secret: DRONE_ACCESS_TOKEN
- base_url: https://code.jcktrue.dk
- files:
- - ledcontroller
- when:
- event: tag
+- name: docs
+ image: corentinaltepe/doxygen
+ commands:
+ - doxygen
+- name: release-dev
+ image: alpine
+ volumes:
+ - name: output
+ path: /output
+ commands:
+ - mkdir -p /output/dev/
+ - cp -r docs/html/* /output/dev/docs/
+
+- name: release-tag
+ image: alpine
+ volumes:
+ - name: output
+ path: /output
+ commands:
+ - cp -r /output/dev/ /output/${DRONE_SEMVER}/
+ when:
+ event:
+ - tag
+volumes:
+- name: output
+ host:
+ path: /home/jct/apps/http/share.jcktrue.dk/${DRONE_REPO_NAME}/
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index f4a914f..ec9a18a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*~
*.swp
ledcontroller
+docs/
diff --git a/Doxyfile b/Doxyfile
new file mode 100644
index 0000000..60dbe51
--- /dev/null
+++ b/Doxyfile
@@ -0,0 +1,7 @@
+PROJECT_NAME = "ledcontroller-3bit"
+OUTPUT_DIRECTORY = "docs/"
+INPUT = "README.md" "main.c"
+RECURSIVE = YES
+WARNINGS = YES
+GENERATE_LATEX = NO
+USE_MDFILE_AS_MAINPAGE = README.md
\ No newline at end of file
diff --git a/main.c b/main.c
index 81f9340..8411336 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/*
+/**
ledcontroller-3bit
This file is a fork of the LedController code. You will find
@@ -39,7 +39,6 @@
along with this program. If not, see .
*/
-
#include
#include
#include
@@ -48,22 +47,8 @@
#define VID 0x1294
#define PID 0x1320
-
static struct libusb_device_handle *devh = NULL;
-
-int main(int argc, char **argv)
-{
- int ret;
- unsigned char code = 0;
- if (argc != 2) {
- printf
- ("Syntax: %s blue | red | green | aqua | purple | yellow | white | off\n",
- argv[0]);
- return -1;
-
- }
-
-/*
+/**
The device has a RGB LED, which has two states for each "sub-LED",
on and off.
The "sub-LEDs" are red, green and blue.
@@ -82,39 +67,66 @@ int main(int argc, char **argv)
1 1 0 yellow 0x6 (more of a mustard - green color)
1 1 1 white 0x7 (a very blue-ish white)
*/
- if (strcmp(argv[1], "blue") == 0) {
- code = 1;
- } else if (strcmp(argv[1], "red") == 0) {
- code = 2;
- } else if (strcmp(argv[1], "green") == 0) {
- code = 3;
- } else if (strcmp(argv[1], "aqua") == 0) {
- code = 4;
- } else if (strcmp(argv[1], "purple") == 0) {
- code = 5;
- } else if (strcmp(argv[1], "yellow") == 0) {
- code = 6;
- } else if (strcmp(argv[1], "white") == 0) {
- code = 7;
- } else {
- puts("Invalid color");
- return -1;
+int main(int argc, char **argv) {
+ int ret;
+ unsigned char code = 0;
+ if (argc != 2)
+ {
+ printf("Syntax: %s blue | red | green | aqua | purple | yellow | white | off\n", argv[0]);
+ return -1;
+ }
+
+ if (strcmp(argv[1], "blue") == 0)
+ {
+ code = 1;
+ }
+ else if (strcmp(argv[1], "red") == 0)
+ {
+ code = 2;
+ }
+ else if (strcmp(argv[1], "green") == 0)
+ {
+ code = 3;
+ }
+ else if (strcmp(argv[1], "aqua") == 0)
+ {
+ code = 4;
+ }
+ else if (strcmp(argv[1], "purple") == 0)
+ {
+ code = 5;
+ }
+ else if (strcmp(argv[1], "yellow") == 0)
+ {
+ code = 6;
+ }
+ else if (strcmp(argv[1], "white") == 0)
+ {
+ code = 7;
+ }
+ else
+ {
+ puts("Invalid color");
+ return -1;
}
libusb_init(NULL);
devh = libusb_open_device_with_vid_pid(NULL, VID, PID);
- if (devh == NULL) {
- puts("Device not found");
- return -1;
+ if (devh == NULL)
+ {
+ puts("Device not found");
+ return -1;
}
- if (libusb_kernel_driver_active(devh, 0)) {
- puts("Detach driver from kernel");
- ret = libusb_detach_kernel_driver(devh, 0);
- if (ret < 0) {
- puts("Could not detach driver");
- return -1;
- }
+ if (libusb_kernel_driver_active(devh, 0))
+ {
+ puts("Detach driver from kernel");
+ ret = libusb_detach_kernel_driver(devh, 0);
+ if (ret < 0)
+ {
+ puts("Could not detach driver");
+ return -1;
+ }
}
char data[5];
@@ -127,11 +139,11 @@ int main(int argc, char **argv)
int dummy;
libusb_claim_interface(devh, 0);
ret = libusb_interrupt_transfer(devh, 0x2, data, 5, &dummy, 0);
- if (ret < 0) {
- perror("libusb error");
- return -1;
+ if (ret < 0)
+ {
+ perror("libusb error");
+ return -1;
}
-
return 0;
-}
+}
\ No newline at end of file