Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c1e9edd
add esp32 vendor and product ID
May 12, 2026
0a2c9d7
Merge pull request #1 from Vtaguiar1909/feature/driver-2.1
denisMoraes21 May 12, 2026
f35812b
feature: read serial
RaphaelvnMello May 12, 2026
584f5f7
Merge pull request #2 from Vtaguiar1909/feature/firmware
denisMoraes21 May 12, 2026
4a1779a
Update usb write serial function
Biancaprs May 13, 2026
5eff61d
Merge pull request #4 from Vtaguiar1909/feature/driver-2.2
RaphaelvnMello May 13, 2026
a7ca490
refactor: changed object makefile to actual task
Vtaguiar1909 May 12, 2026
15a6421
Revert "refactor: changed object makefile to actual task"
Vtaguiar1909 May 12, 2026
c969035
refactor: added the proper target object for driver mock3.1
Vtaguiar1909 May 12, 2026
b6eece5
feat: added mock variables to driver mocking
Vtaguiar1909 May 12, 2026
1752919
feat: added conditional values to print
Vtaguiar1909 May 12, 2026
2dde054
feat: added conditional values to update
Vtaguiar1909 May 12, 2026
b3b0ef7
Revert "feat: added mock variables to driver mocking"
Vtaguiar1909 May 12, 2026
7ae8740
Revert "refactor: added the proper target object for driver mock3.1"
May 14, 2026
38a5b8e
Merge pull request #5 from Vtaguiar1909/feature/driver-mock-3.1
RaphaelvnMello May 14, 2026
e27fa12
feat: added feature to read integer from file
Vtaguiar1909 May 13, 2026
7b83307
feat: added ldr to percent logic
Vtaguiar1909 May 13, 2026
428fd69
feat: added fclose
Vtaguiar1909 May 15, 2026
fd5dbcc
Revert "feat: added ldr to percent logic"
Vtaguiar1909 May 15, 2026
e239f24
feat: ldr to percent logic
Vtaguiar1909 May 15, 2026
12a003b
Merge pull request #6 from Vtaguiar1909/feature/daemon-3.2
RaphaelvnMello May 15, 2026
ea68a44
feat: added read_int_file logic
May 15, 2026
cd16e0a
feat: added write_int_file code
May 15, 2026
9d61d15
add esp32 vendor and product ID
May 15, 2026
29fa58b
implement serial_read function
May 15, 2026
56b92ea
firmware 1.4
RaphaelvnMello May 15, 2026
6ee87d5
Merge pull request #7 from Vtaguiar1909/feature/driver-2.3
denisMoraes21 May 15, 2026
76643ac
feat:added brightness logic
May 15, 2026
c0eedbf
Merge pull request #8 from Vtaguiar1909/feature/firmware_1_4
RaphaelvnMello May 15, 2026
ee863bd
Merge pull request #9 from Vtaguiar1909/feature/daemon-3.2
denisMoraes21 May 16, 2026
88555f4
implement serial_read function
May 16, 2026
e3acce9
Merge pull request #10 from Vtaguiar1909/feature/driver-2.4
denisMoraes21 May 18, 2026
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
smartlamp-brightnessd/
tasks-daemon-2026/
.probe_2025*
probe_2025*
.*.cmd
Module.symvers
modules.order
22 changes: 22 additions & 0 deletions daemon-2026-base/brightnessd_3_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,35 @@ static int read_int_file(const char *path, int *value)
// Retorne 0 em caso de sucesso ou um codigo negativo em caso de erro.
(void)path;
(void)value;

FILE *ftpr = fopen(path,"r");

if(ftpr == NULL) {
return -ENOSYS;
}

int found = fscanf(ftpr,"%i",value);
fclose(ftpr);
if(found > 0) {
return 0;
}

return -ENOSYS;
}

static int ldr_to_percent(int ldr)
{
// TASK 3.2: limite o LDR para 0-100 e aplique um brilho minimo.
(void)ldr;

if(ldr > MIN_PERCENT && ldr <= 100){
return ldr;
}

if(ldr > 100) {
return 100;
}

return MIN_PERCENT;
}

Expand Down
68 changes: 60 additions & 8 deletions daemon-2026-base/brightnessd_3_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

static volatile sig_atomic_t running = 1;

struct config {
struct config
{
const char *ldr_path;
const char *backlight_path;
int interval_ms;
Expand All @@ -40,6 +41,21 @@ static int read_int_file(const char *path, int *value)
// TASK 3.3: reaproveite a implementacao da task 3.2.
(void)path;
(void)value;

FILE *ftpr = fopen(path, "r");

if (ftpr == NULL)
{
return -ENOSYS;
}

int found = fscanf(ftpr, "%i", value);
fclose(ftpr);
if (found > 0)
{
return 0;
}

return -ENOSYS;
}

Expand All @@ -49,6 +65,22 @@ static int __attribute__((unused)) write_int_file(const char *path, int value)
// Use essa funcao para atualizar o brilho real da tela.
(void)path;
(void)value;

FILE *ftpr = fopen(path, "w");

if (ftpr == NULL)
{
return -ENOSYS;
}

int found = fprintf(ftpr, "%i", value);

fclose(ftpr);
if (found > 0)
{
return 0;
}

return -ENOSYS;
}

Expand All @@ -61,6 +93,14 @@ static int ldr_to_brightness(int ldr, int max_brightness)
percent = MIN_PERCENT;
(void)ldr;
(void)max_brightness;
int comparison = ldr * (max_brightness / 100);

if (comparison < percent)
{
return percent;
}
percent = comparison;

return percent;
}

Expand All @@ -71,16 +111,19 @@ static void sleep_ms(int milliseconds)
request.tv_sec = milliseconds / 1000;
request.tv_nsec = (long)(milliseconds % 1000) * 1000000L;

while (running && nanosleep(&request, &request) == -1 && errno == EINTR) {
while (running && nanosleep(&request, &request) == -1 && errno == EINTR)
{
}
}

static int parse_args(int argc, char **argv, struct config *config)
{
int opt;

while ((opt = getopt(argc, argv, "l:b:i:h")) != -1) {
switch (opt) {
while ((opt = getopt(argc, argv, "l:b:i:h")) != -1)
{
switch (opt)
{
case 'l':
config->ldr_path = optarg;
break;
Expand Down Expand Up @@ -123,22 +166,31 @@ int main(int argc, char **argv)
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);

if (read_int_file(max_path, &max_brightness) < 0 || max_brightness <= 0) {
if (read_int_file(max_path, &max_brightness) < 0 || max_brightness <= 0)
{
fprintf(stderr, "failed to read %s\n", max_path);
return EXIT_FAILURE;
}

while (running) {
while (running)
{
int ldr;
int brightness;

if (read_int_file(config.ldr_path, &ldr) == 0) {
if (read_int_file(config.ldr_path, &ldr) == 0)
{
brightness = ldr_to_brightness(ldr, max_brightness);

// TASK 3.3: escreva brightness em brightness_path usando write_int_file().
if (write_int_file(brightness_path, brightness) != 0)
{
return EXIT_FAILURE;
}
printf("ldr=%d brightness=%d max_brightness=%d\n", ldr, brightness, max_brightness);
fflush(stdout);
} else {
}
else
{
fprintf(stderr, "failed to read %s\n", config.ldr_path);
}

Expand Down
5 changes: 5 additions & 0 deletions esp32/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
10 changes: 10 additions & 0 deletions esp32/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
37 changes: 37 additions & 0 deletions esp32/include/README
Original file line number Diff line number Diff line change
@@ -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 changes: 46 additions & 0 deletions esp32/lib/README
Original file line number Diff line number Diff line change
@@ -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
Empty file removed esp32/pinos.txt
Empty file.
16 changes: 16 additions & 0 deletions esp32/platformio.ini
Original file line number Diff line number Diff line change
@@ -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:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
upload_speed = 115200
monitor_speed = 115200
Loading