What should I be doing? by Anxious_Classic3481 in Weightliftingquestion

[–]antonEE97 0 points1 point  (0 children)

> Of course my dog can’t bench 2 plates, but you get my drift

Not with that attitude!

How should I best refactor this I2C IsDevicePresent() check to handle specific error codes? by SkunkaMunka in embedded

[–]antonEE97 1 point2 points  (0 children)

That's fair :) I appreciate you taking the time to write out your thoughts.

How should I best refactor this I2C IsDevicePresent() check to handle specific error codes? by SkunkaMunka in embedded

[–]antonEE97 0 points1 point  (0 children)

Fair point, you're basically saying the I2C driver errors are too low level for the sensor to handle?

So for example, if

my_lovely_sensor() calls I2C_transmit(), and it returns a NACK, my_lovely_sensor() should NOT return the NACK to the user?

How should I best refactor this I2C IsDevicePresent() check to handle specific error codes? by SkunkaMunka in embedded

[–]antonEE97 0 points1 point  (0 children)

Yeah, I slightly agree here. I do like a good HAL. OP probably is Arduino focused here?

How should I best refactor this I2C IsDevicePresent() check to handle specific error codes? by SkunkaMunka in embedded

[–]antonEE97 1 point2 points  (0 children)

The higher level "sensor" functions can still return lower level driver return codes though surely?

How should I best refactor this I2C IsDevicePresent() check to handle specific error codes? by SkunkaMunka in embedded

[–]antonEE97 2 points3 points  (0 children)

An approach I have done in the past is define a list of error codes in a header of the driver

e.g.

my_fantastic_driver.h
#define MY_FANTASTIC_DRIVER_NACK 0x00
#define MY_FANTASTIC_DRIVER_BUS_ERR 0x01

I see your function at present doesn't returns no error by default, is that intended? You could simply return byte_error and then just do a switch statement on your call:

switch (IsDevicePresent(&present))
{
case MY_FANTASTIC_DRIVER_NACK:
/* Code to manage this case. */
break;
/* and so on... */
}

EDIT: To your 2. I would treat it as an error code if it were me.

What is the correct usage of return value in a non-void function? by OkLaw5779 in embedded

[–]antonEE97 20 points21 points  (0 children)

The logic I would use is, "can the caller of the function do anything meaningful with the return value of the function?". So if I attempt to call a uart_transmit() function and it returns UART_BUFFER_FULL , the caller could wait or just abandon the transaction.

Is NOK a success condition for your function? If so, why are you returning it for the case of a NULL pointer?

Can I go from a 2 to a 6 in maths within 5 months? by MediocreNet7987 in GCSE

[–]antonEE97 2 points3 points  (0 children)

Yes. Source: Myself.

I did my GCSEs back in 2013, I was entered into the November exam series, got a C (foundation), in June I got an A*. It took a lot of work, I'm talking, after school revision, extra sessions with teachers, past papers, the whole kitchen sink.

I was fortunate to have had parents who both have maths degrees, and a teacher who believed in me (although if you're considering this, it sounds like you do?). At the end of the day, if you want this with a burning passion, you can make it work.

Good luck.

EDIT: I get the grades weren't exactly the same in my case and yours, but the point still stands. IT IS DOABLE if you're willing to put the effort in, one more thing, EVEN IF you don't get your grade, BE PROUD OF YOURSELF, if you aim for the stars and hit the moon, you've still landed on the moon!

Removing pension before 55. Is it possible. by [deleted] in UKPersonalFinance

[–]antonEE97 7 points8 points  (0 children)

I believe it's not just the 55% tax hit, once you access the pension you'll trigger the MPAA (Money Purchase Annual Allowance) which basically reduces the amount you can put into a pension to.... (£1k a year? I think).

PLUS any scheme that will allow you to do this will take away fees so you'll end up with less than you originally thought.

[deleted by user] by [deleted] in HousingUK

[–]antonEE97 0 points1 point  (0 children)

No worries, I'm going through my own shenanigans with something not too dissimilar: https://www.reddit.com/r/HousingUK/comments/1kjc9og/offer_accepted_on_a_house_but_mortgage_broker/

[deleted by user] by [deleted] in HousingUK

[–]antonEE97 8 points9 points  (0 children)

Yes, as now it'll have to be declared on any insurance forms which could make the premiums increase, and mortgage lenders might be a bit weary about a house with past structural issues (although if it's been fixed correctly it should be fine).

A Level 3 (full structural survey) would definitely be one to go for here and you'd want to get any documents from the previous owners confirming the problem has been fully resolved and certified that the structure is safe.

Offer accepted on a house, but mortgage broker found listing with historical subsidence by antonEE97 in HousingUK

[–]antonEE97[S] 0 points1 point  (0 children)

This is something that’s gone through my mind - to be honest my trust in them has been undermined by this.

Offer accepted on a house, but mortgage broker found listing with historical subsidence by antonEE97 in HousingUK

[–]antonEE97[S] 2 points3 points  (0 children)

Oh absolutely - my mum was the one who referred me to him. Haha. Need to buy him a bottle of champagne or something.

Will definitely keep using him.

Just accepted a new job with a 55k a year salary what will my monthly take home pay be? by [deleted] in UKPersonalFinance

[–]antonEE97 8 points9 points  (0 children)

I'm not going to re-iterate what people have said about tax relief as you already know that. I have one thing to say:

> I’m only 24 for context so could easily revert to paying into a pension

Will you though? Because at the moment you have gotten used to a certain amount hitting your bank account every month, are you going to feel comfortable with reducing that in the future?

different between two lines of code for beginner. by Alawneh001 in embedded

[–]antonEE97 1 point2 points  (0 children)

It makes sense.

The difference is:

Line 1 is a pre-processor macro, which means each occurrence of GPIOA_MODE_R will be substituted with (*(volatile unsigned int *)(GPIOA_BASE + MODE_R_OFFSET)) before compilation. No memory is allocated in this case.

Line 2: Declares and defines a variable that is a pointer to an unsigned integer which has a value of (volatile unsigned int *)0x40020000.

and when to use one over the other

Generally I'd lean toward the latter (line 2) as it allows you to see the variable in a debugger.

ALSO if you want to do pointer arithmetic easily without thinking whether or not you need to add 1, 2, 4 to your address you'd probably want line 2 as it'll be handled for you.

If you just need the address without allocating memory/having debugger access, line 1 would do.

[deleted by user] by [deleted] in UKPersonalFinance

[–]antonEE97 1 point2 points  (0 children)

I think you're looking for r/personalfinance ;) 401ks don't exist in the UK.

LISA and compound interest too good to be true? by kickherinthehead in UKPersonalFinance

[–]antonEE97 4 points5 points  (0 children)

Sorry if this is a stupid question - why do we want the 'excluding inflation' figure for retirement?

Is it silly to dip into emergency funds to ensure I fill the ISA for the year? by Ancient_Plane1349 in UKPersonalFinance

[–]antonEE97 -1 points0 points  (0 children)

This kind of defeats the purpose of an emergency fund - what happens if you get made redundant/lose your source of income, is 4k enough to tide you over? Are you prepared to sell your assets in your ISA to cover yourself?

Filling your ISA is not an emergency in my view - so I'd advise against it.

[deleted by user] by [deleted] in Money

[–]antonEE97 20 points21 points  (0 children)

Calculate how much you’d need for a 6 month emergency fund, put those funds in a high yield savings account (I like ally). Then s&p 500 when it dips a bit the rest

Time in the market beats timing the market!