#Arduino Help

1 messages · Page 4 of 1

wary cloak
#

So idk why we even a mutable reference to serial

#

in the call to the function?

coral geyser
#

so just read_char(serial)

wary cloak
#

A new weird family of unreleated errors appeard

#

Feel like it's messing with me

#

Ah wait

#

No

#

Lcd is mutable

#

And also in the signature of the function says it's a mutable reference

#

And why wouldn't that pop up until now anyways

coral geyser
wary cloak
#

in lcd?

coral geyser
#

yeah

#

or well what does cargo check say

wary cloak
#

Ok unless analyzer it's taking it's time

#

No more errors

#

Just warnings

#

Says serial is unused

#

Which is fairly true as I stated

coral geyser
wary cloak
#

So I will remove it from the signature

coral geyser
#

aka &mut &mut T

wary cloak
coral geyser
#

so we don't need to borrow it again in the function

wary cloak
#

It calls my attention it says read_char is never used

#

When it is inside the functions

#

The other functions yeah they are never used still

#

So now ima finally

#

Replace the code in main with this functions

#

And see if it works

#

What

#

Show drinks have nothing else

#

Btw I tried the &mut on each one also

coral geyser
#

show_drinks(lcd, serial); no fn

wary cloak
#

Bruh

#

Says it doesn't found it in scope

#

But

#

There's the module imported

#

Oh

#

Don't tell me

#

Use create

coral geyser
wary cloak
#

Crate*

coral geyser
#

or a use lcd::*;

wary cloak
#

Wouldn't it clash with the other?

coral geyser
#

lcd::show_drinks(...)

#

use crate::lcd::*; ferrisGlasses

coral geyser
#

This is a pain

wary cloak
#

The use crate worked but it says

#

In don't use it

coral geyser
wary cloak
coral geyser
#

If not then the main module can't see it

#

the cargo check would tell you that

wary cloak
#

Ok done

coral geyser
#

step #1 of my Gentoo spring cleaning, sudo has now been replaced by doas

wary cloak
#

With all

#

Finally it seems..

#

Let me run cargo check

#

Yeaaag

#

Now I'mma test it

#

It takes it's time to answer to my commands tho

#

But it works aside from that

#

Now finally

#

Let's talk about that state machine

#

I'm curious about this good practice

#

When I should do a state machine, why I could have problems with state, and why is it better? And you know that

coral geyser
#

A state machine allows you to manage the state (data) and transitions between states in a formalized way

wary cloak
#

It's just for human readability or could states go out of control?

coral geyser
wary cloak
#

What I understood is that my programms has a default state, then by calling a function, receivimg an order it changes state, and then goes back to defaull, tracking what the current state of the program is could be problematic and I could do a state machine to manage which state it's in and what it should do in it and change to another or smth, like make the states apparents

coral geyser
#

yep

wary cloak
#

Am I right or there's something wrong?

#

Ok

coral geyser
#

This should help a lot with the RFID stuff also as you can manage the states for that

wary cloak
#

We will implement it in a new module?

coral geyser
wary cloak
coral geyser
#

probably a good idea

wary cloak
coral geyser
#

sure, sounds good

wary cloak
#

Done

#

So, how do we start?

coral geyser
#

k, first step is to make a

enum State {
  ...
}
wary cloak
coral geyser
#

You should make a variant in the enum for each state you want the micro controller to have right now (try to match the current code)

wary cloak
#

Default counts?

#

Because then it would go I think

coral geyser
#

This enum isn't set in stone, so you can change it later if you need to

wary cloak
#

Default_state
Drink_selection_state
Intensity_selection_state
Waiting_state

Then back to default

#

How I defined the variants inside the enum?

coral geyser
#

So

enum State {
  Wating,
  SelectDrink,
  SelectIntensity,
  Dispensing,
}
#

?

wary cloak
#

Why isn't default there?

coral geyser
#

I though waiting may be a good name for it

#

but you can swap them if you want to

wary cloak
wary cloak
coral geyser
wary cloak
#

So we created an enum that contains all program's states

#

What now?

coral geyser
# wary cloak What now?

Now we probably want some data to go with it

struct App {
  state: State,
  ...
  selected drink?
  selected intensity?
}
#

Both of these can also be enums

wary cloak
#

Mmmm? What kind of data?

coral geyser
#

as you just have 3 options on screen

wary cloak
#

What to do in that state?

coral geyser
coral geyser
wary cloak
#

I don't get what data should follow

#

And what are the next enums about

#

Are we making enums for enums?

coral geyser
#
enum Drink {
  OptionA,
  OptionB,
  OptionC,
}

as example

wary cloak
#

Oh so the options of the menu when it's in each state

#

I don't get yet why we want that but sure I'll do so, I guess only for select drink and intensity because dispensing does only waiting and the other is merely waiting for something to happen

#
enum Drink {
    OptionA,
    OptionB,
    OptionC,
}

enum Intensity {
    Strong,
    Medium,
    Weak,
}
#

Only these two ig

coral geyser
wary cloak
#

I would not because their names are just temptative, kinda placeholders because is a bartender but we are kinda gonna test it with water and colorants

#

so i made this place holders as well

coral geyser
#

Oh okay

wary cloak
#

tho i could also change their names later but

#

i would have to replace all instances

coral geyser
#

So now

struct App {
  state: State,
  selected_drink: Option<Drink>,
  selected_intensity: Option<Intensity>,
}
wary cloak
#

You lost me a little bit

#

So I create a struct

#

Tha has as fields

#

The state of my program

#

So I can set it and change it

#

And

#

fields for the drink and intensity that I guess would be stored in my struct as my program goes because is info I need

#

And it's wrapped in the options enums because it can be null for example at the start of the program

#

I got it right?

coral geyser
#

yep

wary cloak
#

Tho shouldn't we call it something else?

#

Tho I'm thinking what

#

Let's see it stores the drink, intensity and state of the program..

#

I was thinning maybe of barman/bartender because that's what's the code about but I had that name for a function in the original that I want to ofc do here too

#

Tho Bartender could be this struct's name and barman that name's function

#

Or don't better likely

#

So you like Bartened or it isn't enough descriptive ?

#

Bartender*

coral geyser
wary cloak
#

What would follow now?

coral geyser
#

okay now it's common to have a function like

impl Bartender {
  pub fn update(&mut self) {
    ...
  }
}

that we will call in a loop so it can automatically update it's state

wary cloak
#

Oh

#

So not a new function but rather and update one?

#

And how do me generalize that it changes to the next state? Or are we doing and update for each one?

#

"New"*

coral geyser
wary cloak
#

So a new function and then an update function I see

coral geyser
#

Now because we have the state we can call helper methods to do each state's "stuff" (like printing to the screen or checking for user input)

pub fn update(&mut self) {
  match self.state {
    State::Waiting => self.do_waiting(),
    ...
  }
}

fn do_waiting(&mut self) {
  ...
}
wary cloak
#

What are considered helper functions?

coral geyser
wary cloak
#

Oh ok

coral geyser
wary cloak
#

Like

#

We have an update function

#

That changes the current state

#

To the next

#

But

#

How do me make so it updates always to the next, because it would like something generic that could be called it doesn't matter the state

coral geyser
#

ah

fn do_waiting(&mut self) {
  // print to screen

  // wait for user input
  
  self.state = State::SelectDrink;
}
#

after the state is set the update method returns, and then the main will call update again with the new state

wary cloak
#

I think I more or less get it

#

So how do I start update , I set it to waiting or ask the state?

coral geyser
#

This is a basic version of a state machine. there are more complex ways to set them up, but this should do for now

wary cloak
#

Oh wait

#

So are we gonna do

#

A match

#

And it matches the sate

coral geyser
wary cloak
#

It calls the function

#

And updates the state?

coral geyser
#

yep

wary cloak
#

So I call our functions defined in lcd?

coral geyser
#

yep, we can add lcd and serial to the Bartender struct so you have them

wary cloak
#

And if it matchs to waiting I merely update to SelectDrink?

coral geyser
wary cloak
#

Yes, when it starts it goes to that screen

coral geyser
wary cloak
#

Yeah

#

Tho I'm using that name for the last state

coral geyser
#

that works

coral geyser
wary cloak
#

So

#

When it matches select drink

#

I call show_select_drink

#

And then return state as select_intensify?

coral geyser
#

yep

wary cloak
#

Ok I am going to try to do update and show it to you

coral geyser
#

What this structure lets you do is change/add to the states and the transitions between them without having to redo all your code

wary cloak
#

How do you accept auto completion?

coral geyser
wary cloak
#

Because here in grey is what I want to write

#

But I don't know to tell it, yeah that is, write it

coral geyser
#

usually its Tab then enter

wary cloak
coral geyser
#
fn do_select_drink(&mut self) {
  write!(lcd, "test"); // lcd doesn't exist here
}
wary cloak
#

So how do I re write the struct?

#

Btw here is update

#
impl Bartender {
    pub fn update(&mut self) {
        match self.state {
            State::SelectDrink => {
                show_drinks(&mut lcd, &mut serial);
                return State::SelectIntensity;
            }
            State::SelectIntensity => {
                show_intensity(&mut lcd, &mut serial);
                return State::Waiting;
            }
            State::Waiting => {
                show_waiting_screen(&mut lcd);
                return State::SelectDrink;
            }
        }
    }
}
coral geyser
wary cloak
#

Ah lifetimes..

coral geyser
#

We can just give ownership

wary cloak
#

I mean I ain't against I should learn how to use them

#

But also yeah why not give ownership

coral geyser
#

I don't think they would actually help here

wary cloak
#

It's update good?

coral geyser
wary cloak
#

But don't I have to pass them as parameters still?

coral geyser
wary cloak
#

Wait so now show_drinks became a method of my struct?

#

So since it's now a function from my struct and also a reference from an owned value of the struct it can do it's stuff?

coral geyser
#

yep

wary cloak
#

But it's now a method because is in the impl block right?

#

Because if inside the impl block I do that it seems like it hasn't been declared a method yet to use it that way in update

#

Or well idk I got a little bit confused

coral geyser
wary cloak
#

I get that

#

But

#

I'm treating as a method before making it such?

#

Or is it like the both steps are done at the same time?

coral geyser
wary cloak
#
impl Bartender {
    pub fn update(&mut self) {
        match self.state {
            State::SelectDrink => {
                self.show_drinks();
                return State::SelectIntensity;
            }
            State::SelectIntensity => {
                self.show_intensity();
                return State::Waiting;
            }
            State::Waiting => {
                self.show_waiting_screen();
                return State::SelectDrink;
            }
        }
    }
}
#

So it's update done now?

coral geyser
#

instead of returning the state, inside of each method (show_drinks, ...) have it do self.state = State::...;

wary cloak
#

Oh like

#

Setting it's new state itself

#
impl Bartender {
    pub fn update(&mut self) {
        match self.state {
            State::SelectDrink => {
                self.show_drinks();
                self.State = State::SelectIntensity;
            }
            State::SelectIntensity => {
                self.show_intensity();
                self.State = State::Waiting;
            }
            State::Waiting => {
                self.show_waiting_screen();
                self.State = State::SelectDrink;
            }
        }
    }
}
#

Finally (?

coral geyser
wary cloak
#

I didn't understand that

coral geyser
# wary cloak I didn't understand that

The state transitions can happen anywhere you want, but it would make sense that the code handling each state would perform the transitions when needed from that state

wary cloak
#

So you say that

#

I go to the definitions of show drink and bla bla

#

And add that last line I added in each arm at the end?

#

And just that? Will the function understand in it's context defined in other module what's self?

coral geyser
#

in an impl Bartender {}

wary cloak
#

So lcd Module will die?

#

Because all it has is that functions and the read char that they need

coral geyser
wary cloak
#

That one is in the I2C module

coral geyser
#

oh, hmm

wary cloak
#

Lcd module has the three functions for the states of display

#

And read_char

coral geyser
#

you could keep them in there, but just the logic to display to the screen. Then move the read char to the methods on the Bartender

wary cloak
#

Tho I won't kill it I'll leave it for the last function which is planned to be done at the end but what I was saying is if I copy and paste all the module lcd to state with few changes

#

I don't understand at all

#

So..

#

I move read_char to a impl block for Bartender in state module and that's it?

coral geyser
#

no, um one moment

#

I need to write quite a bit to show the layout

wary cloak
#

Mm?

coral geyser
#
// === main.rs

fn main() {
    // setup pins
    // setup lcd
    // setup serial
    
    let mut bartender = Bartender::new(lcd, serial);
    
    loop {
        bartender.update();
    }
}


// === i2c.rs

pub struct LcdConneciton {
    ...
}

...


// === lcd.rs

pub fn show_select_drinks(lcd: &mut Display<LcdConnection>) {
    write!(lcd, ...);
    ...
}

pub fn show_select_intensity(lcd: &mut Display<LcdConnection>) {
    write!(lcd, ...);
    ...
}

pub fn show_waiting(lcd: &mut Display<LcdConnection>) {
    write!(lcd, ...);
    ...
}
#

// === state.rs

enum State {
    SelectDrink,
    SelectIntensity,
    Waiting,
}

enum Drink {
    ...
}

enum Intensity {
    ...
}

struct Bartender<Serial> {
    state: state,
    selected_drink: Option<Drink>,
    selected_intensity: Option<Intensity>,
    lcd: Display<LcdConneciton>,
    serial: Serial,
}
#
impl<Serial> State<Serial> where Serial: Read<u8> + Write<u8> {
    pub fn new(lcd: Display<LcdConnection>, serial: Serial) -> Self {
        Self {
            state: state::SelectDrink,
            selected_drink: None,
            selected_intensity: None,
            lcd,
            serial,
        }
    }
    
    pub fn update(&mut self) {
        match self.state {
            State::SelectDrink => self.do_select_drink(),
            State::SelectIntensity => self.do_select_intensity(),
            State::Waiting => self.do_waiting(),
        }
    }
    
    fn do_select_drink(&mut self) {
        lcd::show_select_drinks(&mut self.lcd);
        
        match read_char(&mut self.serial) {
            '1' => { self.selected_drink = Some(Drink::OptionA) },
            '2' => { self.selected_drink = Some(Drink::OptionB) },
            '3' => { self.selected_drink = Some(Drink::OptionC) },
        }
        
        self.state = State::SelectIntensity;
    }
    
    fn do_select_intensity(&mut self) {
        lcd::show_select_intensity(&mut self.lcd);
        
        match read_char(&mut self.serial) {
            '1' => { self.selected_intensity = Some(Intensity::OptionA) },
            '2' => { self.selected_intensity = Some(Intensity::OptionB) },
            '3' => { self.selected_intensity = Some(Intensity::OptionC) },
        }
        
        self.state = State::Waiting;
    }
    
    fn do_waiting&mut self) {
        lcd::show_waiting(&mut self.lcd);
        
        ...
        
        self.state = State::SelectDrink;
    }
}

fn read_char(serial: &mut (impl Read<u8> + Write<u8>)) -> char {
    ...
}
#

That is the idea for the layout (That was a lot of typing to do from memory 😥 )

wary cloak
#

A...

#

I only struggle to understand the last message

wary cloak
#

Now with that

coral geyser
wary cloak
#

I struggle to understand the last message for example the first impl block with some many serials and stuff but I think I might slowly get it

#

Ok so

coral geyser
wary cloak
#

You make an impl block for State which takes a generic Serial that implement the traits we saw before , and then creat the new function which takes ownersgip of lcd a serial and returns an instance of self, with state in select drink, selected drink none, intensity none and the ownership of serial and lcs

#

Lcd*

#

Tho

#

I think you meant

#

An impl for the struct bartender

coral geyser
#

My brain is starting to turn to mush 🧠

wary cloak
#

Only that detail

#

Yeah I get it

#

Now I understood new

#

Now let's see update..

coral geyser
wary cloak
#

It's normal too much text you much to remember

#

You don't have the code in front of you

coral geyser
wary cloak
#

It would be so nice if you could have the code to see like a vs file or smth

wary cloak
#

I mean wouldn't that make it waaay easier to you?

#

No I mean you

#

Mine

#

Not me

coral geyser
#

ah, yeah. I would do a shared session even

#

I feel like I should have thought of that before this ferrisForgor

wary cloak
#

Ok I understood your structure

#

I'll try to impl it

coral geyser
#

I think I need to sleep now

wary cloak
#

Understandable have a nice day(?

#

Well now I'll try to do this

#

It should work

coral geyser
#

you too, hope i was helpful 💤

wary cloak
#

And tomorrow there's only one thing left so finally.. Finally.. Lcd can be done

#

Also.. I'll try to buy or get an usb

#

So you know we do all the preparation so I can actually take this to school and test, show, keep programming

#

That's important

wary cloak
#

I like helping people but I don't know if I would get that far

#

But I think having met people like you I need to return that kindness for the world.

#

to the*

coral geyser
#

I have a hard time explaining things, so I practice by helping on this discord

wary cloak
#

Anyhow, I hope I can get an usb or I'll have to wait a whole week to show this -

wary cloak
coral geyser
#

thanks

wary cloak
#

Now get your deserved sleep I'll try this say whenever I made it or what happened and finally go to sleep too.

#

I hope I make it

#

Well I had one problem

#

How weird

#

For a weird reason

#

It doesn't find the module or smth

#

So display, the functions etc can't be used

#

I don't understand because I have just the same use statements in the other modules and this didn't happen so it doesn't make any sense

#

You see some extra uses in that photo that was in case that could work

#

I tried like in the lcd I had a similar problem with i2c

#

Just use the use crate statement

#

Didn't work

#

As you refer to lcd:: directly in some cases

#

Use only mod

#

Also didn't work

#

Add nothing, also didn't work

#

It's so frustrating

#

Why won't importing a module in the same folder work or have problems randomly

#

It just doesn't make sense and I tried anything that made even the slightest of sense and nothing-

#

And even if I couldn't import the module functions are public and I called them with lcd::

#

It's just dumb

#

Actually in the others I didn't need to import the modules and just use

#

use crate ::lcd::* for example

#

But he says unused import

#

Ok I solved part of it

#

It kinda overlapped when you did

#

Lcd::show for example

#

With me using crate:: lcd and etc

#

But for any reason you couldn't use lcd:: without importing anything?

#

It's weird

#

And it's a shame because not only it looked good and I liked it

#

But also it made it clear to you where to look for that function

#

Ok..

#

In the state crate

#

I listened to the compiler an added this

#
use crate ::lcd::*;
use crate::LcdConnection;
use embedded_hal::serial::{Write, Read};
use lcd::Display;
#

Idk why because in lcd they are but as long as it works

#

Then

#

The Match expressions it said they were non exhaustivr

#

So I made the _ catch all and return and empty touple because I think it will never happen so, only to make the compiler happy

#

Also you made a slightly mistake

#

But ofc of memory so it's fine

#

In the match read char of intensity you used as Variants again option a b and c

#

And it was strong medium weak

#

Also for some reason

#

The compiler told me

#

Hey serial doesn't have to mutable

#

And I said well if you say so

#

And now finally..

#

No more errors..

#

Let's test it please work

#

Well again it's taking it's time to answer to my commands for some reason

#

The choose a valid number and drink not available in menu 1

#

Worked perfectly

#

But I pressed 1

#

I waited and it didn't change menu

#

Pressed 1 again and it did

#

Now here in select intensity

#

Pressed 3,nothing

#

Pressed 3 a second time, it worked it changed to waiting and came back

#

I will test it again to make sure but it seems like it works but for any stupid reason you have to insert two correct inputs but incorrect inputs work fine?

#

Yes that it's exactly what happens

#

It doesn't make sense

#

Maybe it has to do with the empty touple.. I don't think so mm..

#

Ah I see

#

You call in do show bla bla

#

Read char again

#

That happens it seems?

#

I'll try by matching to the variable I assign to the function, tecla, maybe it works

#

It says it doesn't find tecla in that scope tch..

#

The other solution is to call it in the match expression you do in do show drinks

#

And there match the variants of not available and so but..

#

It is really verbose and makes the original function less powerful

#

Well I really will get nothing of sleep so I better stop hear

#

I implemented what you showed me, make it so there were no errors nor warnings

#

Tested it, it mostly works except from one error I discovered exactly what it was

#

The only thing left is that we come up with a solution tomorrow

wary cloak
#

Oh no..

#

I didn't ask how big the pendrive should be

#

And today I have to buy one -

#

Damn it

#

I'm having troubles with getting an usb, we should've talked this more before -

#

The problem is I only have this subject on Wednesdays that makes it problematic because I have to wait a whole other week if I don't get it this time

wary cloak
#

@coral geyser quick, what usb so I need(?

#

I guess the only specific is size right?

#

Then it would up to how many GB I need at the very minimum

coral geyser
#

Not sure how that translates to price

wary cloak
#

So whatever usb that has at least 8 GB would do?

#

Because then I see if I can buy a 16 GB one

coral geyser
#

Yeah, I don't think the install will be bigger than 8Gb

wary cloak
#

I'm only going to use for the rust setup and maybe saving codes there instead of sending them to myself via mail

#

Well then today we would have to do that so tomorrow I could start my rust journey at school and show how the rewriting is going

#

Is going to take long or is it easy?

coral geyser
#

It shouldn't be that hard to setup

wary cloak
#

Nice

#

Btw have you seen what happened yesterday?

#

Well I fixed all the errors but

#

Why they happened not entirely sure

#

Tho the thing that matters is the last that everything works but we are calling read_char two times, that's the only thing to fix idk why I could just have a inmutable borrow for tecla

wary cloak
#

Now that I think about it, you said you work with python what do you so?

#

I thought you worked as an embedded developer maybe

#

Tho with python ig is either data science(with is portion of machine learning and ai) or web development, unless you did embedded in the raspberry pi pico and choose to use micro python instead of Arduino ide or c++

#

Which I don't know why would you unless you hated them so much

coral geyser
#

Simulation systems for satellite control

wary cloak
#

Wow that sound complicated

#

Why in python tho?

coral geyser
wary cloak
#

Finally home

wary cloak
#

Tho I'm gonna be busy from 21:30 to 23:30 (my hour ofc) because I have my python course

#

Class about inheritance

#

Aside from that ofc I'm free since tomorrow I'm presenting the rust alternative I want it to be as developed as possible

wary cloak
#

I have a borrowed pendrive

#

Are you available? Well if not just tell me when, if not eating or in the course I'll be

#

Today we finish the lcd once and for all

wary cloak
#

If I'm not*

wary cloak
#

Well eating finished so that's no longer something that could get in the way

#

But I start my class in. .

#

40 minutes

#

@coral geyser are you here for 40 minutes?

#

38*

coral geyser
wary cloak
#

And then

#

After this 36 minutes

#

In 2 hours would you? I can stay asleep again

coral geyser
#

I have some plans later, not sure exactly when though

wary cloak
#

I hope god helps me and it's during those 2 hours (?

#

So what should we do first

#

The pendrive stuff so at least I can guarantee I'm taking something tomorrow

coral geyser
wary cloak
#

Or continue with the little it's left

wary cloak
#

What will we pass?

#

The paths and files or also the codes?

coral geyser
#

pass?

wary cloak
#

Because if the codes then it wouldn't be updated

wary cloak
coral geyser
#

Oh we can make it so it just allows you to compile any cargo project

wary cloak
#

Well we will go through it

coral geyser
#

then if you update it you would just copy it over

wary cloak
#

Do I connect the usb?

coral geyser
#

yeah

wary cloak
#

Done

#

What now?

coral geyser
#

go into the flash drive and make a folder called "rust_toolchain"

#

We will install it in there

wary cloak
#

How do I access the pendrive?

#

Forget it it's literally called

coral geyser
#

in the file explorer

wary cloak
#

Pendrive in the files

coral geyser
#

okay now go find the folder "C:/Users/[your user]/.cargo" in another file explorer window

wary cloak
#

No clue how to

coral geyser
wary cloak
#

Ok I guess I have it

coral geyser
# wary cloak

copy the ".cargo" and ".rustup" folders over to the "rust_toolchain" folder you made

wary cloak
#

Well let's wait a little bit ig

coral geyser
#

cool, now I need to write a powershell script for you. As i don't think you want to memorize the setup you need to do to use it

wary cloak
#

PowerShell script?

#

And what setup are we exactly speaking of?

coral geyser
#

Rust needs some stuff setup, like that PATH we originally did

wary cloak
#

Yeah that whole thing..

coral geyser
#

but so you don't have to do it every time, I can just make a script for it

wary cloak
#

Not only for rust but more so for Arduino hal

wary cloak
#

Cargo it's at 25% of copying

#

I'm making the setup for my class in the meantime

#

Even tho I shouldn't if possible I would try to you know continue working on rust at the same time or smth

coral geyser
#

Do the computers there have editors?

#

Like vscode?

wary cloak
#

Yeah some have vs code and also arduino ide

#

Tho I wouldn't have my extensions ofc

#

72%

#

Takings it's time

#

Well my class it's about to start but at the very least I'll try to completely pass the folders

#

98% cargo

#

And well when those two are done I tell you to see if I can continue even in class

#

The state problem should be easily solved

#

Cargo has been passed

#

Next up rustc

#

Rustup*

#

Wow so many elements..

#

Just how heavy is all this-

coral geyser
#

It should come to about 0.5Gb to 0.8Gb

wary cloak
wary cloak
#

I didn't see cargo

#

Just for curiosity

#

What's next after this?

#

Because

coral geyser
#

yeah, it gets bigger the more you use cargo/rustup

wary cloak
#

I guess this would allow me to code rust in vs code

#

But Arduino_Hal

#

It's another story

coral geyser
#

I will let you know how it goes

wary cloak
#

Sure

#

Tho it will be weird only this does because you know that two hour install and all, having rust in nightly

#

I'm wondering if my internet went really slow merely because it's shit or this transfer is killing itn

wary cloak
#

62%

#

Eventually getting there

#

Well I have a break

#

Let's see how's doing

#

Idk why it's taking longer than cargo I thought cargo was more problematic

#

It's like installing it for the second time tho maybe slower

#

Well in the mean maybe we could try to solve the match issue ig or smth like that

#

We could do other stuff too but that would be seem that more reasonable

wary cloak
#

Aaand

#

My class is done

#

You know what also is done

#

Passing rustup and cargo to the pendrive

#

Finally

#

So what now?

#

Maybe also pass vs code to have my extensions? (Does that make sense?)

wary cloak
coral geyser
wary cloak
#

I disconnected the usb until you came back

#

Imma plug it again

wary cloak
#

Well answering to my on question no because I don't see it in there

#

That one that was in the path we defined?

#

(I went to environment variables to look for it)

wary cloak
coral geyser
#

copy the whole bin folder over

wary cloak
#

Ok so bin folder from Arduino

#

Shouldn't I copy something from the Arduino hal like idk the specs or smth?

#

Done

coral geyser
# wary cloak

was in a session of Startcraft 2, sorry for the delay

wary cloak
#

Np

coral geyser
#

So now copy over your project folder (the one with src/, Cargo.toml) to the usb drive but not in the rust_toolchain folder

#

just the main folder

wary cloak
#

I didn't understand

#

Because you said

#

Not in the rust_toolchain folder but

#

That's the only folder we created for the pendrive

coral geyser
wary cloak
#

So I create another one?

#

Let's better go step by step first

#

Which of the two projects

#

The lcd one

#

Or the test one

coral geyser
#

the one you want for tomorrow

wary cloak
#

Well the lcd because it's the only one we have, now I can ask

#

So.

#

I would move

#

The current state of the program

#

And if we

#

Update it

#

I will need to erase the one from the pendrive and do it again?

#

Tho I could also send me via mail the changes and copy paste or smth like that but aside from whatever I do to fight I want to know that

#

Which also applies to when in school I make it better ofc

coral geyser
#

It will be able to have more than one project on the usb drive at a time

wary cloak
#

Well for now we have only one project so

#

You teel me to

#

Grab my

#

"rust_lcd" Folder

#

Which has the src, specs, target,cargo, lock bla bla

#

And also copy it

#

But not in in the folder we made

#

Called rust_toolchain

#

But rather outside

#

Right?

coral geyser
wary cloak
#

So I guess I would need this from every project

#

Tho there won't be that many

#

Lcd is almost done and when it is,matricial keyboard will have it's own which will be short, and the next is the base functionality of the project, then one only for the rfid and finally the final version of the project

#

Is there any more steps to the set up for tomorrow?

coral geyser
#

I need to get you the script so we can test using the usb drive

wary cloak
#

Well I was going to ask you if that was all how I you know entered and use it when I'm at the school and all

wary cloak
#

I guess for changes to the programm

#

I will pass myself the code via mail

#

And replace the current one

#

I will have to install the vs code extensions in that PC every Wednesday tho

#

But well

#

The script will be the last step?

coral geyser
#

I think so

wary cloak
#

Well in the meantime

#

Let's see or think

#

How could we solve the problem of logic the program currently has

#

I still don't know why my original solution didn't work, it made complete sense, and the alternatives I thought of aren't that pleasant

coral geyser
#

what was the behavior again (you can just link me the message if you want)

wary cloak
#

Here I tested when finally got rid of the errors

coral geyser
wary cloak
#

Like in which part?

#

I have all the code copied here in discord (?

#

If you wanna check any module

#

In particular

#

Tho as I said for me it's because we are calling read twice first in the function second in the match

wary cloak
#

In the state module you made it so matching what read returns it changes the state, the problem is you called the function before to show the particular menu and it also uses that function so I needed to correct inputs to break out

#
use crate ::lcd::*;
use crate::LcdConnection;
use embedded_hal::serial::{Write, Read};
use lcd::Display;

enum State {
    SelectDrink,
    SelectIntensity,
    Waiting,
}

enum Drink {
    OptionA,
    OptionB,
    OptionC,
}

enum Intensity {
    Strong,
    Medium,
    Weak,
}

pub struct Bartender<Serial> {
    state: State,
    selected_drink: Option<Drink>,
    selected_intensity: Option<Intensity>,
    lcd: Display<LcdConnection>,
    serial: Serial,
}

impl<Serial> Bartender<Serial> where Serial: Read<u8> + Write<u8> {
    pub fn new(lcd: Display<LcdConnection>, serial: Serial) -> Self {
        Self {
            state: State::SelectDrink,
            selected_drink: None,
            selected_intensity: None,
            lcd,
            serial,
        }
    }

    pub fn update(&mut self) {
        match self.state {
            State::SelectDrink => self.do_show_drinks(),
            State::SelectIntensity => self.do_show_intensity(),
            State::Waiting => self.do_show_waiting_screen(),
        }
    } 
#
fn do_show_drinks(&mut self) {
        show_drinks(&mut self.lcd, &mut self.serial);
        
        match read_char(&mut self.serial) {
            '1' => { self.selected_drink = Some(Drink::OptionA) },
            '2' => { self.selected_drink = Some(Drink::OptionB) },
            '3' => { self.selected_drink = Some(Drink::OptionC) },
            _ => (),
        }
        
        self.state = State::SelectIntensity;
    }

    fn do_show_intensity(&mut self) {
        show_intensity(&mut self.lcd, &mut self.serial);
        
        match read_char(&mut self.serial) {
            '1' => { self.selected_intensity = Some(Intensity::Strong) },
            '2' => { self.selected_intensity = Some(Intensity::Medium) },
            '3' => { self.selected_intensity = Some(Intensity::Weak) },
            _ => (),
        }
        
        self.state = State::Waiting;
    }

    fn do_show_waiting_screen(&mut self) {
        show_waiting_screen(&mut self.lcd);
        
        self.state = State::SelectDrink;
    }
}



pub fn read_char(serial: &mut impl Read<u8>) -> char {
    loop {
        if let Ok(current_char) = nb::block!(serial.read()) {
            let current_char = current_char as char;
            if current_char != '\n' && current_char != '\r' {
                return current_char;
            }
        }
    }
} 
coral geyser
#

why does show_drinks need serial?

wary cloak
#

Because it needs to see what you pressed to or show, unvalid input, drink not available or either break the loop an end the function

#

Do you want to see the definition of the function?

wary cloak
#
use crate::i2c::*;
use crate ::state::*;
use ::lcd::*;
use embedded_hal::serial::{Write, Read};
use core::fmt::Write as _;

pub fn show_drinks(lcd: &mut Display<LcdConnection>, serial: &mut (impl Write<u8> + Read<u8>)) {
    loop{
        lcd.display(
            DisplayMode::DisplayOn,
            DisplayCursor::CursorOff,
            DisplayBlink::BlinkOff);
        
        lcd.position(3, 0);
        write!(lcd,"Elija una bebida").unwrap();

        lcd.position(1, 1);
        write!(lcd, "1-Fernet con Coca").unwrap();

        lcd.position(1, 2);
        write!(lcd, "2-Sex on the beach").unwrap();

        lcd.position(1, 3);
        write!(lcd, "3-Agua").unwrap();

        let tecla = read_char(serial);

        match tecla as char {
            '1' => break,
            '2' | '3' => {
                lcd.clear();

                lcd.position(3, 0);
                write!(lcd, "Bebida").unwrap();

                lcd.position(3, 1);
                write!(lcd, "No disponible").unwrap();

                arduino_hal::delay_ms(1000);
                },
            _ => {
                lcd.clear();

                lcd.position(3, 0);

                write!(lcd,"elija un").unwrap();

                lcd.position(3, 1);

                write!(lcd,"valor valido").unwrap();

                arduino_hal::delay_ms(1000);
            },
        }
    }
} 
#
pub fn show_intensity(lcd: &mut Display<LcdConnection>, serial: &mut (impl Write<u8> + Read<u8>)) {
    loop{
        lcd.clear();
        lcd.position(0, 0);
        write!(lcd,"Elija la intensidad").unwrap();

        lcd.position(1, 1);
        write!(lcd, "1-Suave").unwrap();

        lcd.position(1, 2);
        write!(lcd, "2-Medio").unwrap();

        lcd.position(1, 3);
        write!(lcd, "3-Fuerte").unwrap();

        let tecla = read_char(serial);

        match tecla as char {
            '1' | '2' | '3' => break,
            _ => {
                lcd.clear();

                lcd.position(3, 0);

                write!(lcd,"elija un").unwrap();

                lcd.position(3, 1);

                write!(lcd,"valor valido").unwrap();

                arduino_hal::delay_ms(1000);
            },
        }
    }
}

pub fn show_waiting_screen(lcd: &mut Display<LcdConnection>) {
    loop {
            lcd.clear();
            lcd.position(3, 1);
            write!(lcd,"Preparando...").unwrap();

            lcd.display(
                DisplayMode::DisplayOn,
                DisplayCursor::CursorOn,
                DisplayBlink::BlinkOn);

                arduino_hal::delay_ms(10000);

                break;
    }
} 
#

Finally

coral geyser
# wary cloak ```rust use crate::i2c::*; use crate ::state::*; use ::lcd::*; use embedded_hal:...

ah these should be

pub fn show_drinks(lcd: &mut Display<LcdConnection>, serial: &mut (impl Write<u8> + Read<u8>)) {
    lcd.display(
        DisplayMode::DisplayOn,
        DisplayCursor::CursorOff,
        DisplayBlink::BlinkOff);
    
    lcd.position(3, 0);
    write!(lcd,"Elija una bebida").unwrap();

    lcd.position(1, 1);
    write!(lcd, "1-Fernet con Coca").unwrap();

    lcd.position(1, 2);
    write!(lcd, "2-Sex on the beach").unwrap();

    lcd.position(1, 3);
    write!(lcd, "3-Agua").unwrap();
}

where the

'2' | '3' => {
    lcd.clear();

    lcd.position(3, 0);
    write!(lcd, "Bebida").unwrap();

    lcd.position(3, 1);
    write!(lcd, "No disponible").unwrap();
    },
_ => {
    lcd.clear();

    lcd.position(3, 0);

    write!(lcd,"elija un").unwrap();

    lcd.position(3, 1);

    write!(lcd,"valor valido").unwrap();
},

(notice I removed the delay_ms from these)
are 2 more functions that the

match read_char(&mut self.serial) {
    '1' => { self.selected_drink = Some(Drink::OptionA) },
    '2' => { self.selected_drink = Some(Drink::OptionB) },
    '3' => { self.selected_drink = Some(Drink::OptionC) },
    _ => (),
}

code will run

match read_char(&mut self.serial) {
    '1' => { self.selected_drink = Some(Drink::OptionA) },
    '2'|'3' => {
      show_error();
      delay_ms(20000);
     },
    _ => {
      show_invalid_drink_error();
      delay_ms(20000);
    },
}
#

Notice on an error we don't change states

wary cloak
#

I got kind of lost

#

So first you removed the tecla = read_char(serial) part and begginning of match so I don't end the loop now and I can't match to 2 and 3

#

Yeah I really got lost

coral geyser
#

They should just print to the lcd and return

wary cloak
#

Let's keep on with the pendrive when we are done we finish this or if there's another waiting for it to copy

#

Oh

#

Ok I can get that part.

#

But

coral geyser
#

the match statements that are in there get moved to what state.rs does

wary cloak
#

Why remove the tecla = statement and the first of match and that

#

Mmm

wary cloak
#

And also since it isn't in a loop

#

Would it come back to ask again or you get it wrong?

wary cloak
coral geyser
coral geyser
wary cloak
#

So..

#

First

#

I remove the loops from the functions

#

Because the state will take care of what to do now

coral geyser
wary cloak
#

Then

#

In both the show drink and selection

#

I maintain the match statement but

#

'1' would return no break

#

But 2 or 3 would stay the same

#

Right?

#

Oh no

#

You pointed that part to be replaced

#

So..

#

Show drinks and show intensity

#

I get rid of the loop

#

¿And also the match?

coral geyser
wary cloak
#

It would just be the lcd printing the stuff and the match statement below would take care of answering for the user's input

wary cloak
#

And we would change

#

do show drinks

coral geyser
#

yes

wary cloak
#

And create a functions to print the error messages, right?

coral geyser
wary cloak
#

And do show intensity and waiting would remain the same?

coral geyser
#

yes

wary cloak
#

Ok got it I'll try to change it

coral geyser
wary cloak
#

Yeah ofc that

wary cloak
#

self.state = State::SelectIntensity;

coral geyser
wary cloak
#

Why?

coral geyser
#

because we want to show the selection screen again

wary cloak
#

Oh

#

Ok I get it know

#

?

#

Tho doesn't this seem a function for the lcd module?

#

I tried put it in the impl block

#

Neither

#

I have no clue how to implement this function

coral geyser
#

Also we need to change the usb

#

we need to actually copy over the avr folder that bin was inside of

coral geyser
wary cloak
#

First outside or inside the impl block?

coral geyser
wary cloak
#

Oh

coral geyser
#

we need the folder that bin/ was in

wary cloak
#

Oh

#

Btw I did the functions

#

In the lcd module

coral geyser
#

this folder

wary cloak
#
fn show_error(lcd: &mut Display<LcdConnection>) {
    lcd.clear();

    lcd.position(3, 0);
    write!(lcd, "Bebida").unwrap();

    lcd.position(3, 1);
    write!(lcd, "No disponible").unwrap();
}

fn show_invalid_drink_error(lcd: &mut Display<LcdConnection>) {
    lcd.clear();

    lcd.position(3, 0);
    write!(lcd, "Bebida").unwrap();

    lcd.position(3, 1);
    write!(lcd, "No disponible").unwrap();

    arduino_hal::delay_ms(1000);
}
wary cloak
coral geyser
coral geyser
wary cloak
wary cloak
coral geyser
wary cloak
#

Oh

coral geyser
wary cloak
#

I copy avr to tool chain anyways?

coral geyser
wary cloak
#

Well I did the implementation

#

Corrected some errors

#

I found along the way or things that needed to be changed

#

Now I only have warnings

#

Drink warning I can ignore because in the future maybe I will add so options B and C are valid

#

But the first one calla my attention a bit

coral geyser
# wary cloak

oh, ```rust
'1' => {
self.selected_drink = Some(Drink::OptionA);
self.state = State::SelectIntensity;
},

#

sort of important to actually switch states on that one 🤦‍♂️

wary cloak
#

Ok now it should do

#

Damn it

#

More warnings

#

Well I said the drinks one I can ignore

#

Ok now I think finally..

#

GOD SAKE

#

Ok now I can run cargo check

#

And then test this works

#

If so the lcd by it's own it's complete leaving one step referring to finishing the code but two to finish this like it's individual project

#

Mmm

#

Small detail

#

I have a pendrive in my usb port

coral geyser
#

you can eject it

wary cloak
#

It's still copying avr

#

Ok it's done doing so

coral geyser
#

oh, OH

wary cloak
#

So now to the usb it's only the script left, right?

coral geyser
#

yeah, though looks like we will want to run cargo run at least once on it, because it's rebuilding everything (I have a test usb drive)

wary cloak
#

Well now let's test this

#

Ok it already doesn't work

#

I presses 5

#

It said drink not available

#

I think you colocated them backwards

#

Well us technically

coral geyser
#

yeah probably, I was doing 2 things at once

wary cloak
#

No

#

Two also says

#

Drink not available

#

Hmmm..

#

That's.. Weird

#

Ah I see

#

This is my error

coral geyser
#

maybe you made both '2'|'3' and _ call the same function

wary cloak
#

Both functions are equal in definition

#

Give me a bit

#

Also I added this

#
fn do_show_intensity(&mut self) {
        show_intensity(&mut self.lcd);
        
        match read_char(&mut self.serial) {
            '1' => { self.selected_intensity = Some(Intensity::Strong) },
            '2' => { self.selected_intensity = Some(Intensity::Medium) },
            '3' => { self.selected_intensity = Some(Intensity::Weak) },
            _ =>   {show_error(&mut self.lcd)},
        }
        
        self.state = State::Waiting;
    }
#

It was important and forgotten

#

What. .

#

It still works as bad what..

#

Man I'm really asleep I

#

Changed the signature of the wrong function

coral geyser
#

ah

wary cloak
#

It finally should know..

#

So we can finally finish this of the pendrive also

#

Tho it's a shame not even today we got to finish the lcd, it's really resisting

#

Maybe because it knows just how easy and short are the two next steps

#

Because literally see the matricial keyboard

#

This is the code I made from using the library

#

Of it by itself

#
#include <Keypad.h>

const byte FILAS = 4;
const byte COLUMNAS = 4;

const char keys[FILAS][COLUMNAS] = {
  { '1', '2', '3', 'A' },
  { '4', '5', '6', 'B' },
  { '7', '8', '9', 'C' },
  { '*', '0', '#', 'D' }
};

const byte pinColumnas[COLUMNAS] = {22, 23, 24, 25};
const byte pinFilas[FILAS] = {26, 27, 28, 29};

Keypad keypad(makeKeymap(keys), pinFilas, pinColumnas, FILAS, COLUMNAS);

void setup() {

  Serial.begin(9600);

}

void loop() {

  char key = keypad.getKey();

  if (key != NO_KEY) {
    Serial.println(key);
  }
  
  
}
#

It needed the number of columns and row, the matrix, which pins for columns which for rows and instanciate the object with all that and make map key that turns the matrix into string

#

And then the only thing I did in the code

#

Was call wait for key

#

So it will block and return the key

#

That's it

#

Also if we were so unlucky that we didn't find a library

#

I had made a code for it without it, to detect the key pressed

#
#include <stdio.h>

struct Key {

  byte id;
  char name[5];

};

const struct Key ONE   = {0b10001000, "1"};
const struct Key TWO   = {0b10000100, "2"};
const struct Key THREE = {0b10000010, "3"};
const struct Key KEY_A = {0b10000001, "A"};

const struct Key FOUR  = {0b01001000, "4"};
const struct Key FIVE  = {0b01000100, "5"};
const struct Key SIX   = {0b01000010, "6"};
const struct Key KEY_B = {0b01000001, "B"};

const struct Key SEVEN = {0b00101000, "7"};
const struct Key EIGHT = {0b00100100, "8"};
const struct Key NINE  = {0b00100010, "9"};
const struct Key KEY_C = {0b00100001, "C"};

const struct Key ASTRK = {0b00011000, "*"};
const struct Key ZERO  = {0b00010100, "0"};
const struct Key HASH  = {0b00010010, "#"};
const struct Key KEY_D = {0b00010001, "D"};

#define COLUMNAS 4
#define FILAS 4

const struct Key KEYPAD[FILAS][COLUMNAS] = {
  { ONE, TWO, THREE, KEY_A },
  { FOUR, FIVE, SIX, KEY_B },
  { SEVEN, EIGHT, NINE, KEY_C },
  { ASTRK, ZERO, HASH, KEY_D }
};

void setup() {
  DDRA = 0x0F;
  Serial.begin(9600);
}

void loop() {

  PORTA = 0b00001000;

  for (byte columna = 0; columna < COLUMNAS; columna++) {
    
    
    for (byte fila = 0; fila < FILAS; fila++) {
      
      if (PINA == KEYPAD[fila][columna].id) {
        char imprimir[25];
        sprintf(imprimir, "Se presionó la tecla %s", KEYPAD[fila][columna].name);
        Serial.println(imprimir);
        delay(200);
      }

    }

    PORTA >>= 1;
    
  }

}
#

We could solve the matricial keyboard and add it to the lcd code

#

In no time

#

And also them the relays and so

#

It's only

#

See what intensity was selected

#

And toggle the pin to each relay on off for a delay

#

And I would make a function so I ain't calling things too much I pass it the number of the delays for each case and that's it

#

It's just sending a one to a pin an amount of time no library no nothing

#

We could easily after lcd make that and the project would have it's base functionality already re written

#

That's why I thought I could for tomorrow, I underestimated the lcd really (?

#

Btw it works

#

Except at the end

#

Because it changes to waiting regardless

coral geyser
coral geyser
wary cloak
#
fn do_show_waiting_screen(&mut self) {
        show_waiting_screen(&mut self.lcd);
        
        self.state = State::SelectDrink;
    }
#

I didn't get your proposal

coral geyser
wary cloak
#

What I'm saying is

#

If you choose and unvalid

#

Intensity

#

It goes to the waiting regardless

wary cloak
coral geyser
# wary cloak It goes to the waiting regardless
fn do_show_intensity(&mut self) {
    show_intensity(&mut self.lcd);
    
    match read_char(&mut self.serial) {
        '1' => {
            self.selected_intensity = Some(Intensity::Strong);
            self.state = State::Waiting;
        },
        '2' => {
            self.selected_intensity = Some(Intensity::Medium);
            self.state = State::Waiting;
            },
        '3' => {
            self.selected_intensity = Some(Intensity::Weak);
            self.state = State::Waiting;
        },
        _ =>   {
            show_error(&mut self.lcd);
            delay_ms(20000);
        },
    }
}
wary cloak
#

Ah y see why

#

This it didn't even show the error

#

Ok I changed it

#

This is getting so complicated we should publish it as a library crate so future people do it in 5 minutes -

#

Well not complicated but

#

You know long and all covered

#

Btw it works now so yeah that's done

#

Ok I plug in the usb again?

coral geyser
#

yep, looks like my script works

wary cloak
#

Done

coral geyser
#

First up you will need to download https://frippery.org/busybox/, as I suspect you won't be allowed to run scripts in powershell there, but this should work

wary cloak
#

What a mess all of this -

coral geyser
#

Also running software not actually installed on a computer is always painful

#

Software sort of just expects to be installed properly

wary cloak
#

Ok it's installed, what now?

#

busybox.exe

coral geyser
#

so copy that busybox.exe to the rust_toolchain folder

wary cloak
#

That was quick

coral geyser
#

And after that we can test it

wary cloak
#

Finally, and also bin Dissapeared

coral geyser
#

okay so this is what to do: right click in the folder, and select the "Open powershell here" option to open a new powershell window in that folder

wary cloak
#

The toolchain?

coral geyser
#

yep

wary cloak
#

I mean inside toolchain folder

#

Ok

#

Done

coral geyser
#

And then run .\busybox.exe ash setup_rust_arduino.sh

#

And then you should be left with a shell that you can run commands in

wary cloak
coral geyser
#

yep

wary cloak
#

What now

coral geyser
#

so now this is setup to use the cargo on the usb drive

#

so use cd to move to where the project folder is

#

cd C:\Users\....

wary cloak
#

Well we are in the usb so

coral geyser
#

it works anywhere on the system

wary cloak
coral geyser
#

as long as you run the script first

wary cloak
#

Because in the usb there are literally only two folders

#

Rust tool chain and rust lcd

#

Don't I just CD to rust lcd directly?

coral geyser
#

is the rust_lcd one the updated copy you just finished testing?

wary cloak
#

No

#

The one we previously inserted

coral geyser
#

You can use either for the test

#

So the one on the usb drive is good

wary cloak
#

Yeah because the things is it would take time to re copy

#

Maybe tomorrow I wake up earlier

#

And try to do so

#

So it's easier to have the already good one

coral geyser
wary cloak
#

Don't I just deleted the rust lcd folder in the main folder of the usb and copy again?

coral geyser
#

Also when you use this on another computer, I recommend copying the project folder (containing you .rs files) to the computer's hard drive

#

As running cargo check on files on the USB will cause a lot of read/write which can be slow

wary cloak
#

Here I would do . Code and ready?

coral geyser
coral geyser
wary cloak
#

So..

#

I have my project folder

#

Where I would code in the school

#

But

#

I would compile and run it

#

Opening a windows poweshell window and cd'ing into my project first running the script prior?

#

So the terminal in vs code wouldn't work? But I use this one instead to read the errors, check, and upload it to the Arduino?

coral geyser
wary cloak
#

So I could in the terminal type the script and use it like I normally would?

coral geyser
#

The script just, takes over the shell while it is running

wary cloak
#

Ok so let's go through this one more time.

#

I go to the school

#

Pick a computer

#

Plug in the usb

#

In vs code enter my rust lcd folder or whatever project I wanna work in

#

Then when I wanna check for the errors or finally run it/upload I open inside toolchain a terminal, or in the same vs code as always, run the script and use it as always

#

That's it right?

coral geyser
#

yep

wary cloak
coral geyser
#

optionally, you would copy the rust lcd folder to the computer first edit in there, then copy it back when you are done for the day

#

Just to speed it up (it won't have to read/write to the USB all the time while you edit stuff)

wary cloak
#

Btw I can run for example cargo new so I could start another at school also?

coral geyser
#

Yep

#

And if you have internet there, you can download more libraries

wary cloak
wary cloak
#

Well now imma delete the current lcd folder as a whole to re copy it but ofc with the working version

wary cloak
coral geyser
coral geyser
wary cloak
#

I delete target before copying it to the desktop?

coral geyser
#

this folder you don't want to copy to the USB if possible

wary cloak
#

Tho wouldn't that fuck up the one in my drive?

coral geyser
#

because it's big

coral geyser
wary cloak
#

Oh ok

#

Well now it's just a matter of copying the new version and done

coral geyser
#

target/ contains all the temporary stuff cargo/rustc uses while it does its stuff

wary cloak
#

Tho the computer will just choose to use the one at desktop instead of the one in the pendrive?

coral geyser
wary cloak
#

Oh so.

#

I understand now

#

I plug the usb

#

Copy deleting the target folder

#

My project folder to the desktop

#

And open that one

#

Ok I got it now

coral geyser
#

yeah

#

it will also increase the life of your USB drive

wary cloak
#

Well I also talked to you about what's close to being the next thing to do just because I can't believe it's resisting so much when the next stuff to have the basic functionality I want is so apparently easy -

#

I'm totally fine with it and it's kinda my thing but aren't we maybe over doing it (?

#

I'm surprised of how much code we wrote for this

#

Not as a bad thing (excepting for not getting to the point I wanted to for tomorrow) but I drawed my attention

coral geyser
#

Which add another thing to learn

wary cloak
#

When we finish this, because for school projects there's not place for pride

#

I want you to maybe coach me on how to be more independent maybe

#

Because honestly sometimes it seems like I couldn't write code alone or smth

#

Or I'm always to dependant

coral geyser
wary cloak
#

My school project is merely that important but for all the rest I could do something about it

coral geyser
wary cloak
#

I mean it's in general the original version I needed also someone to help and I got stuck because he disappeared-

#

Tho to be fair

#

I started programming not so many months ago so

#

It was a bit too much

#

Of a first thing for me to do

#

Not knowing C++ barely having learnt C and kind of programming

#

Because supposedly we should've seen C++ and coded much more on Arduino but yeah pandemic didn't allow it

coral geyser
#

You are doing great for a beginner, in programming and embedded software

wary cloak
#

It's like I can totally understand stuff but not do it my own

#

Tho I hope rust to help me do stuff myself because of the friendly compiler so maybe errors aren't so the end of the road

#

So I ain't that afraid

coral geyser
#

The RFID stuff we can come back to

wary cloak
#

When this was done I was going to ask you like a..

#

Step guide or smth to how idk you do stuff

coral geyser
wary cloak
#

For example I would go over

#

Like

#

Ok what did we do in this project

#

What problems we faced and how we solved them

#

How we got what we needed

#

Etc

#

Btw do you use rust for something else than embedded? Because I wanna keep using it but components do be expensive and you know I would maybe just leave it there

coral geyser
#

I use it in computation engines

#

And personal projects

wary cloak
#

Tho I'm not in the season I'm thinking in doing projects still, I'll tell you what I want to do

coral geyser
wary cloak
#

First I re learned C or basically learn it to some extent to introduce into programming, be prepared for the project when it came (this one) and to recover knowledge I should have had, then I learned a lot about Arduino, serial port, codes I did, bla bla and started the project using the libraries and so, then started the python course so next I would learn python to a good degree I'm still at it

coral geyser
wary cloak
#

But I'm the meantime I just

#

Couldn't resist anymore to learn rust

#

I wanted to learn rust and C++

#

C++ out of curiosity, probably job, I am going to see it in university so I want you be prepared also have the knowledge I should have received and so

#

Rust more or less I did, now C++ would be the next if I consider I have nothing else to with rust for now

#

After python C++ and rust

#

I wanted to see the world of web development closer and also that could earn me money,html, css and JS

#

And also I see I need them

#

I saw a video on how to do an online chat with rust

#

It used css and JS stuff and

#

I thought hey this looks cool but I don't know that widely know tools

#

And then I maybe finally stop be satisfied with my options

#

Don't feel like I have something I really want to learn and finally

#

Start actually doing projects

#

To leave the theory field and start actually being a programmer and being better because its only by doing projects

#

Tho to be honest I really like programming but I don't know what I want to progtamm

#

Programm*

wary cloak
#

I'm lost still and I'm really indecisive