The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,091 other followers

Archive for December 24th, 2019

Pythonic

Posted by jpluimers on 2019/12/24

When learning Python, one of the terms to get used to is Pythonic, basically shorthand for a loosely defined idiomatic Python way of writing code.

Some links to help you get a feel for this:

Sometime, I am going to dig into learning how to write Pythonic code for merging and joining dictionaries (preferably those of namedtuple entities). Hopefully these links will help me with that:

–jeroen

Posted in Development, Python, Software Development | Leave a Comment »

Idea: managing a garage door with a modified Marantec switch, some sensors and Raspberry Pi

Posted by jpluimers on 2019/12/24

Some links to get this idea going, incomplete, as I have not yet included Domoticz or OpenHAB links:

I will likely need:

  • some optocouplers to decouple GPIO pins from the Marantec switch and sensors
  • sensors for detecting current state: open/closed/opening/closing/obstructed

Warning on selecting GPIO pins:

When the Raspberry Pi reboots GPIO pins are reset to their default state. This can cause your garage door to open without you issuing a command. Please make sure you pick the correct pins so that you don’t accidentally have your garage door opening after a power loss.

The following pins are pulled HIGH (they output a 3.3 volt signal) on reboot:

  • GPIO0/2
  • GPIO1/3
  • GPIO4
  • GPIO7
  • GPIO8

GPIO14 is configured as a Serial Transmit line, so avoid choosing that pin.

All other pins are pulled LOW (they have a 0 volt signal, same as GND).

If your relay triggers when the GPIO pin goes LOW, then pick a pin that starts out HIGH on reboot. If your relay triggers with the GPIO PIN goes HIGH then pick a GPIO pin that starts out LOW on reboot.

–jeroen

Posted in Development, Hardware Development, Hardware Interfacing, Raspberry Pi | Leave a Comment »

Delphi and generics: some examples of “E2015: Operator not applicable to this operand type”

Posted by jpluimers on 2019/12/24

I don’t have enough time right now to elaborate on the code, so below is a an example of where I bumped into the very non-descriptive [WayBack/Archive.is] E2015: Operator not applicable to this operand type when using generics in Delphi.

Most have to do with comparing types (one of which is similar to comparing interfaces where you need to have a GUID in order to get an as comparison working, see Source: Delphi – Using FastMM4 part 2: TDataModule descendants exposing interfaces, or the introduction of a TInterfacedDataModule).

Like most post-Delphi 2007 language features in Delphi, generics still have rough edges. I doubt this will change anytime soon and I am not alone in this.

The documentation never got update to cover situations involving generics ([Archive.is] E2015 Operator not applicable to this operand type (Delphi) – RAD Studio), so basically this to show some examples you might bump into as well.

Note the code below usually is an indication of code-smell, as was the more elaborate situation I had to use it in. A long term solution for that code was to introduce more polymorphism.

A shorter term solution involves either the use of local variables or type-casting (for the latter, see [WayBack] delphi – Cannot compile constrained generic method – Stack Overflow)

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

 
%d bloggers like this: