原创 Representing Morse codes dot and dashes in C

2015-7-31 18:56 1824 18 19 分类: 消费电子

OK, before we begin, let's remind ourselves that I'm a hardware designer by trade. When it comes to software in general -- and C in particular -- I know only enough to be dangerous.

 

I have a project on the go at the moment. This is a secret squirrel project whose purpose -- for the present -- must remain a riddle, wrapped in a mystery, inside an enigma. Suffice it to say that I wish to use a light-emitting diode LED to flash messages in Morse code.

 

My question pertains to the best way in which to represent, store, and access the Morse code dots and dashes used to represent the numbers and letters.

 

 

Ultimately, I want to be able to initialize a string with a message I wish to transmit using a statement like:

 

   char my_string = "HELLO WORLD";

 

Later, I'll pass this string as a parameter into the function that will actually flash the LED. So, once again, my question is: "What's the best way to represent the dots and dashes associated with the various characters?" My very first pass thought was to store these as character strings themselves -- something like the following:

 

   char string_A = ".-";
   char string_B = "-...";
   char string_C = "-.-.";
      :

 

I know that this technique of using a separate character for each dot and dash doesn’t give the smallest memory footprint, but it does have the advantage of understandability, which is, of course, an important consideration. On the other hand, the scheme shown above -- having individual strings for each of the character -- would be difficult to use.

 

The bottom line is that every approach I can think of is less than optimal or incongruous, which is why I'm inviting your ideas. If you think of anything -- preferably pertaining to this perplexing poser -- please post it as a comment below.

文章评论1条评论)

登录后参与讨论

用户1406868 2015-10-23 14:31

Between me and my husband we've owned more MP3 plryaes over the years than I can count, including Sansas, iRivers, iPods (classic & touch), the Ibiza Rhapsody, etc. But, the last few years I've settled down to one line of plryaes. Why? Because I was happy to discover how well-designed and fun to use the underappreciated (and widely mocked) Zunes are.

用户1406868 2013-6-15 08:04

肯定只是有钱人的专享工具,对于普通民众而言确实不见得是利好的

用户1406868 2013-6-15 08:03

肯定只是有钱人的专享工具,对于普通民众而言确实不见得是利好的

用户1697450 2013-6-10 13:02

当人工智能发展到一定程度,机器人有了自己的思想之后,可能就是人类灾难来临的时候了,因为没人能够保证机器人不会失去控制,或者受病毒、坏人操纵而变得仇视人类,在一个有高度智能的机器人面前,我相信人类是毫无还手之力的。我相信这一天迟早会到来,人是经过几百万年的进化才有现在的科技,而机器人的发展才几十年,而机器人的学习能力是人类远远达不到的,按这样的发展,你觉得几千年,几万年后机器人不会悄悄的“进化”自己的思想来么。

tomfans_771914403 2013-6-4 17:12

所有的科技进步都是一把双刃剑,就看你怎么去应用了。高科技可以改善人类的生活品质,同样也会变成杀人的凶器。。。

用户1602177 2013-6-4 13:49

这就是另一部科幻大片的思考了——《机械公敌》

用户1602177 2013-6-4 13:45

因此,人们期待着科技的发达,也害怕机器的智能化程度~~

用户1602177 2013-6-4 13:43

服务员不好招,这并不是因为劳动力少了吧?!失业人口、无业游民,还是相当多的~~

用户1406868 2013-6-1 14:19

有点意思,

yfy812_845263591 2013-5-31 18:10

正真的危机是机器人无法理解对错,因为人本身无法判出对错,无法给机器人定出规则,好比机器人三规则如何正确理解。伤害一个人却保护了十个人时,又必须作一个选择时如何作。这是社会科学要解决而永远无法解决的问题,于是一部分机器人接受一部分人类的观点,而另一部分机器人接受一部分人类的观点。。。这不遥远,美国人已在搞机器人战士了。
相关推荐阅读
用户3826190 2016-04-29 17:59
Can you improve this BMP display?
Our Caveman Diorama is going to boast a Time Portal, thereby explaining my presence in the scene. ...
用户3826190 2016-04-29 17:56
In progress: Home-made Nixie tube clock
Just to make sure we're all tap dancing to the same drum beat, let's remind ourselves that, someti...
用户3826190 2016-04-29 17:51
Incorporating medication delivery into smartphones
I don’t know about you, but whenever I have to take medications over a period of time, I have a tr...
用户3826190 2016-04-15 17:20
Incredibly handy electronic component testers
Several weeks ago, I was walking around my office building when I ran across my chums Ivan and Dar...
用户3826190 2016-04-15 17:17
A look at electronic component testers
Several weeks ago I was meandering my way around my office building when I ran across my chums Iva...
用户3826190 2016-03-24 11:48
Let Jolly Roger Telephone Co deal with telemarketers
I don’t know about you, but I receive a staggering number of unsolicited telemarketer calls these ...
我要评论
1
18
关闭 站长推荐上一条 /2 下一条