我正在使用Arduino的PTPISO 15740)库(通过USB主机操纵相机设置)。它使用此常量,似乎是某种哈希表数组。问题是我不知道它叫什么,所以我不确定如何在线搜索它,并且由于我不是一个经验丰富的C ++程序员,所以我不知道如何使用它。这是如何运作的?

const ValueTitle<VT_SHSPEED, VT_SHSPEED_TEXT_LEN> ShutterSpeedTitles[] PROGMEM =
{
{0x0c,  {'B','u','l','b',0} },
{0x10,  {' ','3','0','"',0} },
{0x13,  {' ','2','5','"',0} },
{0x14,  {' ','2','0','"',0} },
{0x15,  {' ','2','0','"',0} },
{0x18,  {' ','1','5','"',0} },
{0x1B,  {' ','1','3','"',0} },
{0x1C,  {' ','1','0','"',0} },
{0x1D,  {' ','1','0','"',0} },
{0x20,  {' ',' ','8','"',0} },
{0x23,  {' ',' ','6','"',0} },
{0x24,  {' ',' ','6','"',0} },
{0x25,  {' ',' ','5','"',0} },
{0x28,  {' ',' ','4','"',0} },
{0x2B,  {' ','3','"','2',0} },
{0x2C,  {' ',' ','3','"',0} },
{0x2D,  {' ','2','"','5',0} },
{0x30,  {' ',' ','2','"',0} },
{0x33,  {' ','1','"','6',0} },
{0x34,  {' ','1','"','5',0} },
{0x35,  {' ','1','"','3',0} },
{0x38,  {' ',' ','1','"',0} },
{0x3B,  {' ','0','"','8',0} },
{0x3C,  {' ','0','"','7',0} },
{0x3D,  {' ','0','"','6',0} },
{0x40,  {' ','0','"','5',0} },
{0x43,  {' ','0','"','4',0} },
{0x44,  {' ','0','"','3',0} },
{0x45,  {' ','0','"','3',0} },
{0x48,  {' ',' ',' ','4',0} },
{0x4B,  {' ',' ',' ','5',0} },
{0x4C,  {' ',' ',' ','6',0} },
{0x4D,  {' ',' ',' ','6',0} },
{0x50,  {' ',' ',' ','8',0} },
{0x53,  {' ',' ','1','0',0} },
{0x54,  {' ',' ','1','0',0} },
{0x55,  {' ',' ','1','3',0} },
{0x58,  {' ',' ','1','5',0} },
{0x5B,  {' ',' ','2','0',0} },
{0x5C,  {' ',' ','2','0',0} },
{0x5D,  {' ',' ','2','5',0} },
{0x60,  {' ',' ','3','0',0} },
{0x63,  {' ',' ','4','0',0} },
{0x64,  {' ',' ','4','5',0} },
{0x65,  {' ',' ','5','0',0} },
{0x68,  {' ',' ','6','0',0} },
{0x6B,  {' ',' ','8','0',0} },
{0x6C,  {' ',' ','9','0',0} },
{0x6D,  {' ','1','0','0',0} },
{0x70,  {' ','1','2','5',0} },
{0x73,  {' ','1','6','0',0} },
{0x74,  {' ','1','8','0',0} },
{0x75,  {' ','2','0','0',0} },
{0x78,  {' ','2','5','0',0} },
{0x7B,  {' ','3','2','0',0} },
{0x7C,  {' ','3','5','0',0} },
{0x7D,  {' ','4','0','0',0} },
{0x80,  {' ','5','0','0',0} },
{0x83,  {' ','6','4','0',0} },
{0x84,  {' ','7','5','0',0} },
{0x85,  {' ','8','0','0',0} },
{0x88,  {'1','0','0','0',0} },
{0x8B,  {'1','2','5','0',0} },
{0x8C,  {'1','5','0','0',0} },
{0x8D,  {'1','6','0','0',0} },
{0x90,  {'2','0','0','0',0} },
{0x93,  {'2','5','0','0',0} },
{0x94,  {'3','0','0','0',0} },
{0x95,  {'3','2','0','0',0} },
{0x98,  {'4','0','0','0',0} },
{0x9B,  {'5','0','0','0',0} },
{0x9C,  {'6','0','0','0',0} },
{0x9D,  {'6','4','0','0',0} },
{0xA0,  {'8','0','0','0',0} }
};


本质上,我最终要寻找的是这个。十六进制值表示相机上的快门速度。如果在摄像机显示屏上以单字符形式显示,则十六进制亨伯右侧的数据就是快门速度的值。 (我猜这可以称为矩阵?)。我想插入设备,然后在相机上设置曝光度。我们说一秒钟的曝光,它用十六进制值“ 0x38”表示。这是一个起点参考。

我想拍五张照片。其中之一是“ 0x38”,而其他四个是在此之前的两次曝光,另外两个是在此之后的两次曝光。因此,我想按顺序将所有五个十六进制值放入一个数组中,以便找到“ 0x38”,然后在下面搜索两个,然后在下面找到一个,然后是引用,然后在上面一个,然后在上面两个。

最佳答案

这是一个数组初始化器:

例:

int  val[] = {1, 2, 3, 4}; // initializes an array of ints.


如果您具有struct,则语法相同。

struct X
{
    int x;
    int y;
};

X   valX[] = { {1,2}, {3,4}, {5,6}}; // initializes an array of X
                                     // first X is {1,2}
                                     // second X is {3,4}
                                     // etc


在您的情况下,结构为:

ValueTitle<VT_SHSPEED, VT_SHSPEED_TEXT_LEN>


但是概念是相同的。

关于c++ - 我不明白这种C++语法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13212199/

10-13 08:35