Giter Site home page Giter Site logo

Comments (5)

maximbaz avatar maximbaz commented on September 28, 2024 1

Hello! Exciting to get it it working on MacBook!

To clarify, you changed this config line, and you get the crash, is that right?

path = "/sys/bus/iio/devices"

Could you show me the contents of the folder?

ls -al /sys/devices/platform/applesmc.768/light

Thanks

from wluma.

podbyte avatar podbyte commented on September 28, 2024

Hello! Exciting to get it it working on MacBook!

To clarify, you changed this config line, and you get the crash, is that right?

path = "/sys/bus/iio/devices"

Could you show me the contents of the folder?

ls -al /sys/devices/platform/applesmc.768/light

Thanks

Hi, only just realised there was a config.toml, I pulled it from the AUR and didn't manually build it.
/sys/devices/platform/applesmc.768/light is a file, it reads (x,0) (x is the light level).
I don't know rust but I made a fork and I'm trying to see if I can get it to work.

from wluma.

maximbaz avatar maximbaz commented on September 28, 2024

Lovely! Allow me to give you some general pointers, and feel free to ask for clarification 🙂

In this project, the architecture is already prepared to be plug-and-play for different hardware. iio is just one of many light sensors, and you are the first person to desire to have applesmc type.

First, create a file next to iio.rs and call it applesmc.rs. Inside you will implement the logic that is responsible for letting the rest of the app know about this particular driver.

At the very minimum, your file must contain the implementation for this trait:

wluma/src/als/mod.rs

Lines 11 to 13 in 191e984

pub trait Als {
fn get(&self) -> Result<String, Box<dyn Error>>;
}

In iio.rs, this looks like so:

wluma/src/als/iio.rs

Lines 72 to 80 in 191e984

impl super::Als for Als {
fn get(&self) -> Result<String, Box<dyn Error>> {
let raw = self.get_raw()?;
let profile = super::find_profile(raw, &self.thresholds);
log::trace!("ALS (iio): {} ({})", profile, raw);
Ok(profile)
}
}

and in time.rs, it looks like so:

wluma/src/als/time.rs

Lines 15 to 23 in 191e984

impl super::Als for Als {
fn get(&self) -> Result<String, Box<dyn Error>> {
let raw = Local::now().hour() as u64;
let profile = super::find_profile(raw, &self.thresholds);
log::trace!("ALS (time): {} ({})", profile, raw);
Ok(profile)
}
}

Most likely, you can have exactly the same function, with substituted "raw" value read from your sensor.

What are those "thresholds": your sensor will give some integer values, and we need to convert them to some logical groups. I recommend trying to have the same groups as here ("night", "dark", "dim", etc) - and the numbers are the values from your /sys/devices/platform/applesmc.768/light file under these conditions:

thresholds = { 0 = "night", 20 = "dark", 80 = "dim", 250 = "normal", 500 = "bright", 800 = "outdoors" }

Don't worry too much about getting the perfect values, it's just a default config. But it would be nice for them to be reasonable for most people 😉 How you find them is an art... Go in a dark room, see what value your sensor shows, go in a sunny day outside and see the values, etc...

Once you do this, just fill out the rest of the glue code, like defining config like so:

wluma/src/config/app.rs

Lines 10 to 14 in 191e984

pub enum Als {
Iio {
path: String,
thresholds: HashMap<u64, String>,
},

Extending config.toml with your example commented out, etc, whatever is needed to make the app run 🙂

And good luck, enjoy this exploration!

from wluma.

nullptr-deref avatar nullptr-deref commented on September 28, 2024

Have kind of the same issue as well.
I'm using MacBook Pro (early 2011) and trying to get wluma working properly but it halts with error:

thread 'als' panicked at 'Unable to initialize ALS IIO sensor: "No iio device found"', src/main.rs:112:26

I have

iio:device0
trigger0

under /sys/bus/iio/devices directory which are symlinks somewhere into the Linux deeps.

I tried to set [als.iio] path both to /sys/bus/iio/devices/ and /sys/bus/iio/devices/iio:device0 but had no success.

from wluma.

maximbaz avatar maximbaz commented on September 28, 2024

Judging by what you shared, your laptop might not have iio type of ambient light sensor - you could check inside the iio:device0 folder, there will be a file called name, and it will tell you what this sensor is - wluma will only use sensors whose name is als (and it gets the sensor values from another file in the same directory called in_illuminance_raw.

This thread is about a different kind of sensor that wluma currently doesn't support, called applesmc, you can check if you have this folder on your laptop /sys/devices/platform/applesmc.768/, if yes - implementing this new sensor type this issue will indeed solve the issue for you; if you don't have it, it might be better to open another issue if you would like to continue this investigation 🙂

from wluma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.